Forum Moderators: phranque

Message Too Old, No Replies

Reviving an old website

         

lappert2001

8:56 am on Jan 7, 2020 (gmt 0)

10+ Year Member



I was torn on whether to post this in Apache or PHP, so apologies if in the wrong forum. I'm trying to revive an old website, circa 2005 or so, created with an old version of Movable Type. Running Debian 8, Apache 2.4.10 and PhP 5.6.40

Most of the site is navigating OK, but the contact form is not working. It's an old php form and not part of the Movable Type install. I get nothing when I try to send a test message.

I saw some reference to register globals and considered adding that to the .htaccess, but in the /etc/apache2/sites-available/mysite.com.conf file, I found this:

<VirtualHost *:80>

ServerAdmin webmaster@localhost
ServerName mysite.com
ServerAlias *.mysite.com
DocumentRoot /home/mysite/public_html

<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>

<Directory /home/mysite/>
Options Indexes Includes FollowSymLinks MultiViews
AllowOverride All
AddHandler cgi-script .cgi
Require all granted
</Directory>

<Directory /home/mysite/public_html>
Options Indexes ExecCGI
</Directory>

[<Directory "/home/mysite/public_html/contact" >
php_admin_value register_globals On
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/mysite.error.log
#CustomLog /home/mysite/logs/access.log combined
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/mysite.access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Require all denied
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

</VirtualHost>


And the relevant section of the errorlog shows this:

[Tue Jan 07 02:39:33.133498 2020] [:error] [pid 24542] [client x.x.x.x:38876] PHP Notice: Undefined variable: REMOTE_ADDR in /home/mysite/public_html/contact/phpreview_view.php on line 3, referer: http://mysite.com/contact/contact.html

[Tue Jan 07 02:39:33.133543 2020] [:error] [pid 24542] [client x.x.x.x:38876] PHP Notice: Undefined variable: UserName in /home/mysite/public_html/contact/phpreview_view.php on line 61, referer: http://mysite.com/contact/contact.html

[Tue Jan 07 02:39:33.133556 2020] [:error] [pid 24542] [client x.x.x.x:38876] PHP Notice: Undefined variable: UserEmail in /home/mysite/public_html/contact/phpreview_view.php on line 65, referer: http://mysite.com/contact/contact.html

[Tue Jan 07 02:39:33.133567 2020] [:error] [pid 24542] [client x.x.x.x:38876] PHP Notice: Undefined variable: UserPhone in /home/mysite/public_html/contact/phpreview_view.php on line 70, referer: http://mysite.com/contact/contact.html

[Tue Jan 07 02:39:33.133578 2020] [:error] [pid 24542] [client x.x.x.x:38876] PHP Notice: Undefined variable: UserCountry in /home/mysite/public_html/contact/phpreview_view.php on line 74, referer: http://mysite.com/contact/contact.html

[Tue Jan 07 02:39:33.133596 2020] [:error] [pid 24542] [client x.x.x.x:38876] PHP Notice: Undefined variable: UserRefer in /home/mysite/public_html/contact/phpreview_view.php on line 79, referer: http://mysite.com/contact/contact.html

[Tue Jan 07 02:39:33.133607 2020] [:error] [pid 24542] [client x.x.x.x:38876] PHP Notice: Undefined variable: UserComments in /home/mysite/public_html/contact/phpreview_view.php on line 84, referer: http://mysite.com/contact/contact.html



The phpfile "phpreview_view.php" is:

<?
$ip = $REMOTE_ADDR
?>
<html>
<head>
<title>mysite.com - Review Form</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
<!--
function MM_findObj(n, d) { //v4.0
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') {
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}

function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//-->
</script>
<style type="text/css">
<!--
-->
</style>
<link rel="stylesheet" href="http://mysite.com/contact/formstyle.css" type="text/css">
</head>

<body bgcolor="#8FABBE" text="#0033CC" leftmargin="0" topmargin="10" marginwidth="0" marginheight="10" link="#FF6600" vlink="#FF6600" alink="#FFCC00">
<table width="600" border="0" cellspacing="1" cellpadding="0" align="center" bgcolor="#336699">
<tr align="left" valign="middle">
<td bgcolor="#336699"> <font color="#FFFFFF" face=arial><b><font size="5">Review your submission</font></b></font></td>
</tr>
<tr>
<td align="center" valign="top" bgcolor="#FFFFFF">
<form name="page1" method="post" action="http://mysite.com/contact/phpreview_mail.php" onSubmit="MM_validateForm('UserName','','R','UserEmail','','R');return document.MM_returnValue">
<table width="100%" border="0" cellpadding="4" align="center" cellspacing="5">
<tr align="left" valign="top">
<td colspan="2">This is a preview of the information that will be sent. If you have used your real e-mail address you will receive a confirmation message.<br><b>Please check and edit your message if required.</b></td>
</tr>
<tr bgcolor="#ffE9E9">
<td valign="middle" align="right" width="34%" class="framz"><b><font size="2">Name:</font></b></td>
<td valign="middle" align="left" width="66%" class="framz"><?php echo $UserName ?></td>
</tr>
<tr bgcolor="#ffE9E9">
<td valign="middle" align="right" width="34%" class="framz"><b><font size="2">E-mail:</b></td>
<td valign="middle" align="left" width="66%" class="framz"><?php echo $UserEmail ?>
</td>
</tr>
<tr bgcolor="#ffE9E9">
<td valign="middle" align="right" width="34%" class="framz"><b><font size="2">Phone:</font></b></td>
<td valign="middle" align="left" width="66%" class="framz"><?php echo $UserPhone ?></td>
</tr>
<tr bgcolor="#ffE9E9">
<td valign="middle" align="right" width="34%" class="framz"><b><font size="2">Country:</font></b></td>
<td valign="middle" align="left" width="66%" class="framz"><?php echo $UserCountry ?></td>
</tr>
<tr bgcolor="#ffE9E9">
<td valign="middle" align="right" width="34%" class="framz"><b><font size="2">How
you found us:</font></b></td>
<td valign="middle" align="left" width="66%" class="framz"><?php echo $UserRefer ?></td>
</tr>
<tr bgcolor="#ffE9E9">
<td valign="top" align="right" width="34%" class="framz"><b><font size="2">Your
message:</b></td>
<td valign="middle" align="left" width="66%" class="framz"><?php echo $UserComments ?>

</td>
</tr>
<tr>
<td valign="middle" align="left" width="34%">
<input type="hidden" name="UserName" value="<?php echo $UserName ?>">
<input type="hidden" name="UserEmail" value="<?php echo $UserEmail ?>">
<input type="hidden" name="UserPhone" value="<?php echo $UserPhone ?>">
<input type="hidden" name="UserCountry" value="<?php echo $UserCountry ?>">
<input type="hidden" name="UserRefer" value="<?php echo $UserRefer ?>">
<input type="hidden" name="UserComments" value="<?php echo $UserComments ?>">
</td>
<td valign="middle" align="left" width="66%" bgcolor="#ffE9E9" class="framz">
<input type="submit" name="Back" value="&lt;Edit" class="buttns" onClick="MM_goToURL('parent','javascript:history.back(1)');return document.MM_returnValue">
<input type="submit" name="Submit" value="Submit&gt;" class="buttns">
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>


And the .htaccess file is simply "options -indexes"

Apologies if this ais too much info, but I'm hoping the solution is somewhere here. Thanks for any help on this. Much appreciated.

not2easy

9:51 am on Jan 7, 2020 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



If you can update PHP to a more recent version you should, that version was EOL a year ago.

Your htaccess file may need a line telling it to parse php as html - something like
AddHandler application/x-httpd-php5 .html .htm 
(where the "php5" art depends on the version of php that is in use.

The html should probably not be calling itself <html> which implies html5 and it is some version of html4 at best. Most browsers are highly forgiving, but it can have unexpected issues.

Not sure that any of this will help with your form, but it can't hurt.

lammert

10:25 am on Jan 7, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



[<Directory "/home/mysite/public_html/contact" >
php_admin_value register_globals On
</Directory>

Is the opening square bracket intentional, or a typo?

w3dk

10:42 am on Jan 7, 2020 (gmt 0)

10+ Year Member Top Contributors Of The Month



... and PhP 5.6.40


"Register Globals" was removed completely in PHP 5.4 - so you can't enable it even if you want to (which would seem to be the problem here). (That square bracket must be a typo, otherwise the server will fail to start - won't it?!)

You'll need to manually copy the necessary variables into the global namespace - or (preferably) update your script to use the "correct" variables. eg. $_SERVER['REMOTE_ADDR'] and $_POST['UserName'] etc.

lappert2001

11:19 am on Jan 7, 2020 (gmt 0)

10+ Year Member



Thanks you all for your replies.

To not2easy: yes, you're right, we are trying to get the server Debian updated, which would then hopefully update the php. Until then, we're making do. I will try your suggestion.

To lammert: yes, it's a typo; I was trying to bold that line in this post.

To w3dk: I'll look into your suggestion.

To all: in lieu of fixing this, does anyone know of a simple contact form of more recent vintage I could just plug in?

Again, thank you.

lammert

11:35 am on Jan 7, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Maybe switch to a newer CMS platform altogether? Chances are low that a 2005 Movable Type site will work without modification on a 7.x PHP version so you might consider upgrading to a newer platform that directly integrates contact forms. That could be just upgrading MT to the newest version, or moving to something more mainstream like Wordpress.

lappert2001

12:49 pm on Jan 7, 2020 (gmt 0)

10+ Year Member



Tanks lammert. On other sites, we did update by switching, and that was pretty tedious. But this particular site we hope to bring it back to what it was. A new CMS would create a new look, which we don't want.

As it stands, the MT install itself works well; it's just the contact form that needs to be fixed or replaced. That's why I would also consider a simple replacement (even if done in perl).

lammert

1:42 pm on Jan 7, 2020 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Looking at the function names which all start with MM_ this script was created with Macromedia Dreamweaver. Buying the newest Dreamweaver from Acrobat to just fix this contact form is a little bit overkill :)

But you can install WordPress and use it only for the contact page. It seems a bit overkill to install a full CMS for just one input form, but the installation of it takes just minutes and you'll have the opportunity to move more of the original content of the site into WordPress later on. Many single page websites on the web are currently running on WordPress.

I concur that moving to a newer CMS is a time-consuming job. I did it a few months ago with a Server Side Include file based site from the nineties. But you can do it without switching to a new layout. If your current site is already using CSS instead of hardcoded <font> and other style attributes, it is fairly easy to write your own template for Wordpress and just use the style definitions of the old CMS.