Website not working properly since moving host. GeoIP Issue - php

My website used to work perfectly fine a few months ago. However, since changing host last month some parts of my website no longer work.
I am very sure the issue is related to GeoIP. My website requires the GeoIP php extension for it to work correctly. Both the old and new server have this extension enabled.
I get the following errors on my new server. Please note that the file "pdf_after_checkout_generator" is a custom made plugin.
PHP Warning: include(/usr/share/GeoIP/geoip.inc): failed to open stream: No such file or directory in /home/jksastrology/public_html/wp-content/plugins/pdf-after-checkout-generator/pdf_after_checkout_generator.php on line 18
PHP Warning: include(): Failed opening '/usr/share/GeoIP/geoip.inc' for inclusion (include_path='.:/opt/alt/php56/usr/share/pear:/opt/alt/php56/usr/share/php') in /home/jksastrology/public_html/wp-content/plugins/pdf-after-checkout-generator/pdf_after_checkout_generator.php on line 18
PHP Fatal error: Call to undefined function geoip_open() in /home/jksastrology/public_html/wp-content/plugins/pdf-after-checkout-generator/pdf_after_checkout_generator.php on line 20
I contacted my current host about this issue. I asked them what the file path is for the GeoIP extension on their server. They provided the following response (see bottom of post).
I would appreciate answers to the following questions:
I am not sure how to implement a solution. They are saying the file my website requires is not in their GeoIP extension file. Does this mean I need to install files (within the link they supplied) to my main wordpress site? then point my broken include code to the newly downloaded geoip.inc file?
I have no idea what this particular error is about. It is referencing PEAR, and I am not sure why.
PHP Warning: include(): Failed opening '/usr/share/GeoIP/geoip.inc' for inclusion (include_path='.:/opt/alt/php56/usr/share/pear:/opt/alt/php56/usr/share/php') in /home/jksastrology/public_html/wp-content/plugins/pdf-after-checkout-generator/pdf_after_checkout_generator.php on line 18
Hi there,
This would vary depending on what package you have I suspect, the
server I checked has the dat file (/usr/share/GeoIP/GeoIP.dat) present
but there is no PHP include file there.
The simplest fix would be to move the PHP dependency into the code
base of the application rather than relying on a globally shared
version. We don't as a rule install things like this globally as if it
was then updated and the API changed it would break everyone that
depended on its code.
You would need to check the .inc file on the old server to confirm but
this code is probably the code in this GIT repo so it would be simple
enough to move in to the base application -
https://github.com/maxmind/geoip-api-php

This has nothing to do with pear. The PEAR Net_GeoIP package has no geoip.inc file.
I guess that you have to put the source code of https://github.com/maxmind/geoip-api-php/ into /usr/share/GeoIP/ directory.

Related

Ninja Forms / File Upload issue after site migration

I've got a Wordpress site with a Ninja form that's using a file upload add-on. The form was working just fine on my Godaddy staging server. I migrated the site to another Godaddy account and the form stopped working. Being that the hosting accounts, and all other configuration, were virtually identical, I was stumped to understand what the problem could be.
Then I checked the PHP error logs and saw the following:
PHP Warning: mkdir(): No such file or directory in /new/server/wp-content/plugins/ninja-forms-uploads/.../pre-process.php on line 203
PHP Warning: move_uploaded_file(/OLD/server/wp-content/uploads/ninja-forms/tmp/xEgbu/ninja_forms_field_3332): failed to open stream: No such file or directory in /new/server/wp-content/plugins/ninja-forms-uploads/.../pre-process.php on line 209
PHP Warning: move_uploaded_file(): Unable to move '/tmp/phpqrLDo5' to '/OLD/server/wp-content/uploads/ninja-forms/tmp/xEgbu/ninja_forms_field_3332' in /new/server/wp-content/plugins/ninja-forms-uploads/.../pre-process.php on line 209
PHP Warning: mkdir(): Permission denied in /new/server/wp-content/plugins/ninja-forms-uploads/.../processing/process.php on line 154
(FYI: the ellipsis is just a shorthand for unimportant parts of a file path.)
The thing to notice is the new/server/ and OLD/server/ conflict on the second and third PHP Warnings. For some reason, a Ninja Form script is attempting to move a file from a location on the old server to a location on the new server.
Is it possible that Ninja Forms, upon the initial installation, saved the full path of the server as a reference point in the database? If so, can that be found and adjusted without reinstalling Ninja Forms?
Thanks!
Mark
I suffered this too.
As at the end of https://ninjaforms.com/docs/file-uploads/
If you migrate from another server and the File Uploads path is
pointing to the older server location, you can deactivate then
reactivate your File Uploads and Ninja Forms plugins to reset the file
path.
Had the same issue. And while the suggested steps (of deactivating and reactivation File Uploads and Ninja Forms plugins by fiorebat) might have had some role to play but it didn't resolve the issue for me.
The problem was a really really silly thing .. UTF/Charset encoding issue. To solve that, actually type in % and/or any special characters on the Upload settings section of the File Uploads plugin.
I suspect this happens when both WP have different charsets.
Background: We were using a custom path/destination for File Uploads with %year%/%Mmonth% in the path. When we hardcoded the path to say 2019/7 it worked fine. So next, we manually typed in % (or copy from the samples show on the same page) and it custom/dynamic paths worked as well.

PHP Form on WordPress (4.6.1) site

forgive me if is a basic question...
I am working on setting up a form on our new hosted Wordpress site - currently hosted inhouse on IIS/PHP/Wordpress server (I am not JR - but this stuff escapes me and would really like to figure it out!! I hate not knowing)
The OP that made the form / got it working is no longer around and I am sure there is a better way but this is what I have - a request form.
When I load the required files in the same path - copy the code from the WP page and paste it in the new Wordpress page - it loads without formating, the pick box doesnt look right and when I submit the form - I get these below PHP file errors. I can open the path in my browser and it exists - I see the class.GA_Parse.php file)
I checked execustion rights on the scripts - its set to execute - apart from that I dont know why it cant fine the files and that include_path I dont see via my hosting companys dir structure via FTP.
Any help would put me forever in your debt, I hope to be able to return the help, this site looks amazing!
Cheers,
Warning: require(/gaparser/class.GA_Parse.php): failed to open stream: No such file or directory in /home/comany/public_html/stage/forms/getfreetrial_v3.php on line 4
Warning: require(/gaparser/class.GA_Parse.php): failed to open stream: No such file or directory in /home/company/public_html/stage/forms/getfreetrial_v3.php on line 4
Fatal error: require(): Failed opening required '/gaparser/class.GA_Parse.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/company/public_html/stage/forms/getfreetrial_v3.php on line 4
PHP will load pages based on the disk location, not the URL. This means it's starting in the server's root / directory, not in /home/company/public_html/stage/forms. When including a file, either you have to use a relative link:
require('./gaparser/class.GA_Parse.php'); // starts in the same directory as the file
Or use PHP's server variable to get the document root:
require($_SERVER['DOCUMENT_ROOT'].'/gaparser/class.GA_Parse.php');
The paths may need to be tweaked depending on where the file actually is.

require_once in PHP giving errors on new server, but not on original

I am in the process of moving a PHP website from a shared hosting server to a DigitalOcean server. I have come across an issue that I'm not sure how to debug.
There is a page that has a log-in form with action=2/login.php. This form is located in /var/www/html/calendar.php (it is a Ubuntu 14.04 DO droplet). When submitting the form, there is a 500 Internal Server Error. I've found the error in question but I am not sure how to debug it (because it runs fine on the other server).
/var/www/html/2/login.php
<?php
require_once('../db_connect.php');
...
db_connect.php is located at /var/www/html/db_connect.php
When I $php 2/login.php I get the following error:
login_error.txt
PHP Warning: require_once(../db_connect.php): failed to open stream: No such file or directory in /var/www/html/2/login.php on line 4
PHP Fatal error: require_once(): Failed opening required '../db_connect.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/html/2/login.php on line 4
When I run $php login.php when in directory /var/www/html/2 it works fine (which I guess makes sense, as ../db_connect.php is a relative path).
I want to know why it is working on the other server and not the DO server?
The php.ini is the same (which could be a problem), but on Server #1 (Verve), it is shared hosting, so our root is /home/[username]/public_html and on the new server is is /var/www/html.
I can link to the live sites in question if necessary (but would prefer not to). The /var/www/html/2/login.php and the /var/www/html/calendar.php scripts are exactly the same, and while I understand this will definitely cause issues later as the absolute path to the root of the web application is different, I don't know what would be causing this specific issue.
I have also looked at this question which is very similar: PHP require_once resetting to current working directory. However, this code works on the other server, and not here, so I think there is something more than just a lack of a relative file path, and I would prefer to find the solution that explains why the script isn't working rather than patching the script, as I'm pretty sure I'd have to change every single other script that uses require_once('../db_connect.php') as well.
Thanks for any help!
Did you try using __DIR__?
require_once(__DIR__ . '../db_connect.php');

PHP APC Error Loading apc.so

I recently installed PHP APC on our server via our WHM panel (Web Host Manager). After a successful install, I thought everything was fine. However the next day I noticed our error_log file was getting quite large, after inspection I noticed the following line many times:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20060613/apc.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20060613/apc.so: cannot open shared object file: No such file or directory in Unknown on line 0
Looking into the directory I do not see apc.so, but I also do not see it anywhere else on our server (maybe it is and I just haven't found it). Is there anyway I can generate this file to place into the proper folder? Will this work, or do I need to reinstall something or change a path in some file?
.so files are the equivalents of windows .dll files. you can't just whip one up. You'd have to extract it from the installation package (or recompile it if you started from source code). You can try doing find / -name apc.so to see where it's hiding on the system.

PHP Suddenly stop searching for files in current directory

So I came up against something really strange today.
I've updated my PHP APC to the latest version and restarted apache. And then suddenly all scripts in apache starting complaining about not being able to find required files.
I would usually have:
require_once 'Abstract.php'
considering that Abstract.php is on the same directory as the other script.
The errors where:
PHP Warning:
require_once(Abstract.php) [function.require-once]:
failed to open stream: No such file or
directory in data.php on line 411 PHP
Fatal error: require_once() [function.require]:
Failed opening required 'Abstract.php'
(include_path='/var/www/application/../library:/var/www/library:.:/usr/share/php:/usr/share/pear')
in data.php on line 411
As you can see the current directory (.) is included in the include_path of the execution. Why did this happen? Has anyone seen it before?
AFAIK, the . denotes the directory where the PHP binary resides. require* and include* functions take into account the current working directory, which can be modified via chdir().
As was suggested by cwallenpoole, try using the __DIR__ constant:
require_once __DIR__ . '/Abstract.php';
If that also fails, it means there's a misconfiguration elsewhere. If it works, it probably means the current executing PHP thread has its working directory set to a different and you need to either change the current working directory or modify the require statements to use absolute paths.
Also, have you considered using an autoload callback? That way you have a single point of entry for searching for classes.
Ok, I figured it out eventually and though I should share in case anyone else gets in the same trouble as me.
I used to have APC 3.0.x and upgraded to 3.1.8. As it seems APC on 3.1.8 has a bug that breaks include/requires of PHP.
See relative link here: http://pecl.php.net/bugs/bug.php?id=22687
Thanks everyone for the quick feedback :)

Categories