Wordpress - wp-config.php encoding - erratic behaviour - php

I'm facing a strange problem with my wordpress multisite installation. I have a couple of domains on the same server and depending on which domain I use to access the same file, I get different results.
When I need to access Wordpress Core from pages outside the usual structure, I use the following code:
require_once("../../wp-config.php");
$wp->init(); $wp->parse_request(); $wp->query_posts();
$wp->register_globals(); $wp->send_headers();
echo "test hello";
The execution of this code works fine with all domains but when using some specific domains, 4 blank lines are added to the top of my page.
So on domain name 1, the source code looks like this:
1. test hello
While on another domain, the source code looks like this:
1.
2.
3.
4.
5. test hello
This is exactly the same code, exactly the same file but called from a different domain name.
I have checked the encoding of wp-config.php and it is in UTF8 without BOM while other WP core files are in ASCII. I have tried to convert all other WP Core files in UTF8 without BOM but then I get the 4 lines on all my domains. If I convert wp-config back to ASCII, I still get 4 lines on some domains.
All domains are using the same database, the only difference is the theme used. They are all using different themes but I don't know how this would be related.
I also see the 4 empty lines in Wordpress admin on some domains but not on others.
I'm puzzled :(
Do you have any idea of what it going on? It doesn't prevent pages from being executed but it creates white space on top of every concerned sites (3 out of 15). I have tried reinstalled the current WP version but it didn't solve the issue.
Do you have any idea?
Thanks
Laurent

Related

Wordpress can't edit some pages anymore

My Wordpress website has a strange problem: some pages cannot be updated anymore. It happens not with all pages, a few pages are working without problems.
After saving my edits, Wordpress shows me the message 'Your page is updated successfully' (or some other English translation) but it is not! My edit is gone and there is no extra revision.
What I tried so far:
Disabled all the plugins;
Disabled SSL;
Checked if server / plugin caching was enabled (it was not);
Disabled the browser cache;
Checked the .htaccess file (it's the default Wordpress .htaccess);
Rebuild the entire website (empty FTP and empty database);
Checked my (custom build) template for vulnerabilities;
Enabled the default twenty-seventeen theme;
Repaired the database (in DirectAdmin);
Contacted the webhoster (but they didn't understand the problem);
Moved the website to another domain;
Compared working pages with not working pages (but no difference);
Logged in with different users;
The error / debug log is empty and WP_DEBUG (and some PHP debug stuff) is enabled.
Suggestions are welcome ;)
Solution
I finally found the problem! Wordpress creates a GUID for each post. You can see the GUID in your database, or export your pages using the Wordpress export module.
For some strange reason, the content of the GUID is some text from the page itself. So, it looks like this:
strongWinterwerk%202016-2017/strongU/jij%20bent%20van%20harte%20welkom%20om%20één%20of%20meerdere%20activiteiten%20die%20in%20onze%20gemeente%20worden%20gehouden%20in%20de%20komende%20maanden%20te%20volgen.%20Hierbij%20ontvangt%20u%20de%20seizoenplanning%20en%20meer%20informatie%20over%20clubs%20en%20verenigingen%20
This GUID contains 317 characters. But, the database column can only store 255 characters. I changed it to 500 characters and my website works. Of course isn't this a good solution, but fine for now.
Just a few more questions:
Why is my GUID not just something like http://website.com/welcom-page?
If there is only room for 255 characters, why are there 317 stored while creating the post?

Migrating Wordpress to a site with a subdirectory

I've migrated many Wordpress sites before, but now I'm having an issue I just can't seem to solve. Some, but not all of the links are not loading properly.
I'm migrating from local.dev to example.com/test.
In my database options, I have both options set to example.com/test.
I doubled checked the options in the WP backend, and they're example.com/test.
I've updated my permalinks.
All of the pages work, all of the links work, but a few references to images, etc do not - they're loading example.com/ instead of example.com/test.
I think it might have to do with the .htaccess file, because I can't update it from the FTP side. If I delete it and update permalinks, no .htaccess file is created. I don't have access to any server side overrides, only the files.
In my MAMP vhosts, I have SymLinks Override set to All, but I can't edit anything like that on the live host.
The links that aren't working are along the lines of $image = get_post_meta(37 ,'_my_meta',TRUE)['img']; which should return
http://www.example.com/test/wp-content/uploads/image.jpg
but instead returns
http://www.example.com/wp-content/uploads/image.jpg.
Using bloginfo('wpurl'); returns http://www.example.com/test, and all similar ones return properly (site_url();, 'template_directory', etc.
In the end, the site is going to go on http://www.example.com without the subdirectory anyway, but I'm sure I have to get it to work properly to prevent future errors.
I also updated to the newest version of Wordpress at some point, not sure if that could cause any issues.
I believe the issue deals with media and links placed in content items.
I use to do some manual SQL queries to fix this but now I run this plug-in https://wordpress.org/plugins/automatic-domain-changer/
The plug-in will go through all the content and make the needed changes.
The links that aren't working are along the lines of $image => get_post_meta(37 ,'_my_meta',TRUE)['img']; which should return
http://www.example.com/test/wp-content/uploads/image.jpg
this meta information is stored in the DB. then to make the migration you have to change all the old URL in the DB before to import it in the new place

Wordpress issue - siteurl and home option is being changed every time I log into the admin

I hope you can help me.
For some unknown reason, every time I log into the admin and update the site, afterwards the "siteurl" and "home" paths are always changed to a previously used "testsubdomain". I already hired a developer who gave up telling me that he isn't a Wordpress specialist and can't see where the issue is.
What I have done until now, I just went into the phpmyadmin every time I noticed that it happened again, and changed the entries back to its correct path manually. This has become a real pain because every time this happens, the contact form entries aren't forwarded to the client either, and he is losing potential business.
Can anyone help and point me into a direction of how to fix this?
The site is http://www.chinatownband.com.
Thank you in advance!
Check to see if the URLs are hardcoded in either wp-config.php or the active theme functions.php file. Those are locations that read the URL settings for WordPress and can be used to fix or hardcode the URLs because they will override the URL settings in the database (see http://codex.wordpress.org/Changing_The_Site_URL ).
You're looking for
define('WP_HOME','http://testsubdomain.com');
define('WP_SITEURL','http://testsubdomain.com');
If you find those, delete them and then change to http://www.chinatownband.com in the database with phpmyadmin as you have been doing.
If those settings are not in wp-config.php or the active theme functions.php file, download the whole theme and use a text editor to search the folder for those define lines.
And look in the root web directory for any non-core WordPress files and folders and check them, too.
In the end, you may also need to use https://github.com/interconnectit/Search-Replace-DB to safely find/replace URLs in the database. The URLs you are changing are only the 2 settings URLs and don't retroactively change any URLs in page/post content that are links to media, other pages, etc.

Redirection not working in CakePHP 2

I have an application and its working locally perfect.
on production, all pages are fine which haven't redirection.
Its connected with database because data showing on list pages
I have checked controllers/models for starting and ending code (spaces removed and closing PHP tag removed)
I checked permissions (all folders are 755 and tmp is 777)
I updated debug value to 2,3 but not showing any thing
I checked using PR few variables and in view source it shows few spaces (didn't get any clue that from where the spaces are embedding)
Also, I have uploaded fresh copy of lib/Cake
One another project in same version of Cake is already deployed and working perfectly (Prefix changed for both projects)
On redirection, it shows a blank page. I checked view source of this blank page and it contains 32 spaces.
Any Clue why its happening or from where I need to remove these spaces?
Issue fixed.
Because it was issue of IDE.
I am using sublime but same Dreamweaver have same issue.
For Sublime, we can load a package : https://github.com/SublimeText/TrailingSpaces
For Dreamweaver, we need to do manually by search and replace.
for more details : http://www.jaredstenquist.com/2009/02/13/removing-extra-linebreaks-and-spaces-in-dreamweaver/
Thanks

Help with Clean URLs

I am very new to php (in fact about 2 days old). After getting ripped off by my last webhost I have decided to move my website to a different host. A friend has been helping me do this as he has a little info but we are now stuck and I have tried finding a soloution on google but most answers are way over my head. My site is a php site with a mysql database. We have moved the database and ftp'd the site and everything is now working on the new server except one thing - my site was designed originally to use clean urls? When I go to my shop page (ie: mywebsite.com and click on the shop link - mywebsite.com/shop/ (shows in the bottom left of my browser) I get a page not found error, yet when I type in the url mywebsite.com/shop.php the page displays fine. In addition, if I go to mywebsite.com/shop/shoes/ (another link which shows the preceding link in the bottom left hand corner) I get a page not found error. Also if I type in mywebsite.com/shop/shoes.php in the address bar I also get a page not found error even though the page shoes.php exists on the ftp server in a folder called templates - if I go to mywebsite.com/templates/shoes.php it shows up) I understand this is called clean urls and I need to add an .htaccess file to sort out the issue. I have looked on the ftp area of my old host and cannot find this file but have been told it is probably hidden. I have been told by my new provider that mod-rewrite is available on the server but I have no idea how to write this htaccess file. Can anyone please give me a step by step on how to do this as I am not a coder.
Additional Details
I have the following files in my root directory: index.php, shop.php, checkout.php, completed.php, contact.php ... I then have a folder called templates and in this folder I have: shoes.php. clothes.php, coats.php ...
The issue I am having is that most of the php files in my root directory already have href-links? pointing to places like mysite.com/shop/ and mysite.com/shop/shoes/ so when I open up the home page in my browser and hover over the links these are the addresses I see and when I click on the links I get page not found as the borwser must be looking for the links in the wrong place. (these links worked fine however on the last host I used). I understand I need an htaccess file to re-direct these links to the correct places. - ie the link for mysite.com/shop/shoes/ is actually linking to a page called shoes.php located in root/templates. I understand this method was used to tidy up the urls?? ie: instead of having mysite.com/templates/shoes.php the urls shows mysite.com/shop/shoes/. I have looked at the code within some of the php pages in the root and they all have lots of links to these 'false' addresses - ie: mysite.com/shop/shoes/ when the actual file should be at mysite.com/templates/shoes.php. I don't want to go through each file one at a time as they are hundreds of links, thus the reason for trying to make this htaccess file. Thanks for your time, Dave
Try to find an option on your FTP client software to show hidden files.
The name of this file is .htaccess (dot htaccess), that is probably the reason you're not seeing it. If the old site is working then the file is probably there. You could also contact somebody to send you the file via e-mail, IM, etc.
You do not need mod_rewrite or .htaccess for this.
Turn on multiviews in your Apache configuration. This will allow you to omit the .php extension from your URLs.

Categories