Go Back    Forum > Digital Publishing / Web Sites > Website and Server Troubleshooting

Reply
 
LinkBack Thread Tools
  #1  
01-24-2011, 12:45 PM
kpmedia's Avatar
kpmedia kpmedia is offline
Site Staff | Web Hosting, Photo
 
Join Date: Feb 2004
Posts: 4,311
Thanked 374 Times in 341 Posts
I've been using the WPAds WordPress plugin for several years now, both for banner ad rotation, as well as simply rotating images and content easily on the site. It's an excellent tool for randomizing the design!

The Problem

Anyway, the plugin was built to use PHP "magic quotes".
This means that the php.ini must have "magic_quotes_gpc = on"
However, in more recent years, this was determined to be unsafe, and is in fact be deprecated (obsoleted and removed) from future versions of PHP 5.x and PHP 6. Shared hosts will undoubtedly have magic_quotes turned off, and VPS/dedicated users are strongly urged to repair their PHP code to not use it, in order to have the best server/website security.

When magic_quotes is turned off, the wp-admin Settings controls for WPAds will not work correctly -- you'll have forward-slashes injected into your script. So if you try to add or edit existing WPAds entries, when magic_quotes is off, you'll get errors. For example:

Here's the proper code used in the "ad" spot (for randomizing the header image):
PHP Code:
<img src="http://www.site.com/wp-content/themes/mytheme/images/homemain1.jpg" alt="" /></img
And here's what happens to it when you edit/add and save new code, with magic_quotes off:
PHP Code:
<img src=\"http://www.site.com/wp-content/themes/mytheme/images/homemain1.jpg\" alt=\"\" /></img> 
Look at all the extra slashes that break your site!

And here's what that generates to the browser:
PHP Code:
http://www.site.com/%22http://www.site.com/wp-content/themes/mytheme/images/homemain1.jpg/%22 
Instead of the proper code:
PHP Code:
http://www.site.com/wp-content/themes/mytheme/images/homemain1.jpg 
Quick Note: If you move a site, where WPAds is in use on a server with magic_quote on, to a server where magic_quotes is off, and DO NOT CHANGE the settings of the ads, then you won't notice that anything is wrong. Only the admin panel of WPAds uses magic_quotes -- not the functionality of the script itself. I've actually been running two sites on a server without magic_quotes for about two years now, and never noticed that anything was wrong. WordPress continued to receive updates, but the design of the site was never changed (WPAds used for design randomness and not serving advertising). The original site was designed somewhere else long ago (magic_quotes "on"), then moved to an "off" server.


The Solution

The solution is to simply remove the magic_quotes PHP -- or as I prefer to do, simply comment out the old code (in case, for whatever reason, you need to know what the old code was).

... or just download the new version I've attached to this post.

If you want to edit your own code, simply change this:
PHP Code:
    if (get_magic_quotes_gpc()) { 
        foreach( 
$banner as $key => $value ) {
            
$banner[$key] = stripslashes$value );
        }
       } 
to this:
PHP Code:
/*    if (get_magic_quotes_gpc()) { */
        
foreach( $banner as $key => $value ) {
            
$banner[$key] = stripslashes$value );
        }
/*       } */ 
This code appears twice in the wpads-options.php file, under the wpads folder (or whatever you may have renamed the folder to), under the wp-content/plugins folder.

Change both instances. And that's it.


The New Version for Download

You'll find the attached file download at the bottom of this top post. To get access to download the files, simply join the forum as a Free Member (it's free!) and that's it. You'll be able to download. We provide files like this for the convenience and support of our members, including both Free and Premium Members. We don't send spam or sell your e-mail addresses.

If you're not sure what to do with the attached ZIP or RAR files, then read this help post. Although, as a WordPress user who's likely downloaded/installed quite a bit of code (themes + plugins), I'm hoping you know what a RAR file is!


Attached Files
File Type: rar wpads-without-magicquotes.rar (6.0 KB, 16 downloads)

- Did my advice help you? Then become a Premium Member and support this site.
- Please Like Us on Facebook | Follow Us on Twitter

- Need a good web host? Ask me for help! Get the shared, VPS, semi-dedicated, cloud, or reseller you need.
Reply With Quote
Someday, 12:01 PM
admin's Avatar
Ads / Sponsors
 
Join Date: ∞
Posts: 42
Thanks: ∞
Thanked 42 Times in 42 Posts
Reply




Similar Threads
Thread Thread Starter Forum Replies Last Post
WordPress plugins for better admin and SEO admin Website and Server Troubleshooting 0 04-29-2010 04:58 AM
GetResponse code in WordPress? plugin? admin Website and Server Troubleshooting 0 04-07-2010 10:05 PM
More pages per page in WordPress admin kpmedia Website and Server Troubleshooting 0 01-03-2010 10:39 PM
Wordpress wp-admin login loop [SOLVED] admin Website and Server Troubleshooting 0 10-08-2009 02:20 PM
Looking for WordPress music sidebar plugin for band site admin Website and Server Troubleshooting 0 10-07-2009 08:14 AM

Thread Tools



 
All times are GMT -5. The time now is 03:36 AM