Click to See Complete Forum and Search --> : Can't remove javascript from PHP?


classified
02-15-2007, 08:48 PM
I have been trying to remove a script from my site that disables users from right clicking and copying my website. Its just a pain in the rear for folks using my site. However, every time I try and delete or modify the script I get an error message like this one.

warning:[function.main] failed to open stream. no such file or in
directory/home.php on line 43
...and I get the error anywhere I have this line of include code on the page
<? include('anyfile.php'); ?>
Why would removing a javascript cause the rest of my site to loose its functionality?

I have included the javascript below(red) as it is written at the end my home.php code.

Any suggestions to how I can remove or modify it would be very appreciated.

<? include('featured.php'); //fetch 5 featured properties ?>
</td>
</table></td>
<td height="15"><img src="images/pixel.gif" width="1" height="1" alt=""></
<td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<td class="pageTitle">Featured Article</td>
###FETCH FEATURED NEWS FROM SETTINGS
$settingsSql = 'select * from settings where id = 1';
$settingsR = mysql_query($settingsSql,$myconn) or die(mysql_error());
$settings = mysql_fetch_assoc($settingsR);
$featuredSql = 'select * from news where id = '.$settings['defaultNewsID'];
$featuredR = mysql_query($featuredSql,$myconn) or die(mysql_error());
$featured = mysql_fetch_assoc($featuredR);?>
<div class="pageSubTitle"><? echo $featured['title']; ?></div>
<div class="pageText"><? echo substr($featured['description'],1,300);,<br>
<a href="fullnews.php?id=<? echo $featured['id']; ?>" class="pageLink">Full Story
</tr>
</table>
<SCRIPT LANGUAGE="JavaScript1.1">
<!-- Begin
function right(e) {
if (navigator.appName == 'Netscape' &&
(e.which == 3 || e.which == 2))
return false;
else if (navigator.appName == 'Microsoft Internet Explorer' &&
(event.button == 2 || event.button == 3)) {
alert("Sorry Pal, Permission Disallowed !");
return false;
}
return true;
}
document.onmousedown=right;
document.onmouseup=right;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (document.layers) window.captureEvents(Event.MOUSEUP);
window.onmousedown=right;
window.onmouseup=right;
// End -->
</script>

NightShift58
02-15-2007, 08:58 PM
I don't think it's related...

Which one is Line 43?

classified
02-15-2007, 09:21 PM
Line 43 on the home.php page is

<? include('featured.php'); //fetch 5 featured properties ?>

NightShift58
02-15-2007, 09:44 PM
The error message is telling you that it can't find this file. It isn't related to having removed the javascript.

Is that file (featured.php) in the same directory as the script trying to include it?

classified
02-15-2007, 09:54 PM
Yes that featured.php file is in the same directory.

And my site works perfectly fine (view here http://www.classifiedsrealtor.com/ ) untill I remove that java script and then I recieve the errors telling me that the include scripts can not find the .php files they are looking for.

NightShift58
02-15-2007, 10:35 PM
It looks like the script header.php is not without problems.

Try correcting the HTML <header> to <head< and </header> to <head>.
Then put the <link rel> to the style sheet inside the <head> block.

Still, the error is not related to the removal of the javascript.

classified
02-16-2007, 07:10 AM
Thank you for the heads up on the header.php and I will fix the HTML.

Although, I am still unclear as to why you don't think their is a relation between removing the javascript and the errors I receive when I delete the script. Again, the only time I receive the errors is if I remove or modify that script.

Please explain and thank you for your time..

NightShift58
02-16-2007, 08:07 AM
Quite simply because it would mean that no PHP script in the world would be able to run properly without embedded javascript - which is not the case.

If you'll post header.php, I will test it on my server. But a preliminary test with the file you posted and a palcebo header.php ran equally well when I removed the javascript at the end of the PHP script.

I can only reiterate that the error message you are getting is a function of some other error - possibly in the header.php and not due to the removal of the javascript.

classified
02-16-2007, 03:41 PM
I attached a .txt file with the header code in it. Please let me know if you need anything else.

NightShift58
02-17-2007, 06:17 PM
(1) Remove the javascript
(2) Correct <header> to <head>
(3) There is an exttraneous </ in your code thatalso needs to be removed

classified
02-17-2007, 07:12 PM
I corrected the code and removed the script and then when I accessed my site all that showed up was white background with this error:

Warning: main(classifiedssite/public_html/Connections/myconn.php) [function.main]: failed to open stream: No such file or directory in /home/class12/public_html/header.php on line 5

Fatal error: main() [function.require]: Failed opening required 'classifiedssite/public_html/Connections/myconn.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/class12/public_html/header.php on line 5

NightShift58
02-18-2007, 05:29 AM
This means that it cannot find the file "Connections/myconn.php", which is being included by header.php.

Is the path correct? The path is the path from where the main script is running and not from where header.php is stored....