Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

HTML Forum


You are currently viewing our HTML Forum as a guest. Please register to participate.
Login



Post a Project »

Find a Professional HTML Freelancer!

Find a Freelancer to help you with your HTML projects

FREE Outsourcing eBook!

Reply
Easy "report" function
Old 06-27-2007, 11:12 AM Easy "report" function
John84's Avatar
Skilled Talker

Posts: 64
Name: John
Trades: 0
Hello,

Looking to simplify the process of reporting broken links. Is there a way to create a button/link that emails me specific information (url of broken link) when the user clicks it without having to fill out a form?

Did I even make sense there?

Thanks in advance
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
John84 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-27-2007, 01:59 PM Re: Easy "report" function
LadynRed's Avatar
Defies a Status

Posts: 10,017
Location: Tennessee
Trades: 0
It makes sense, but you're going to need some server-side scripting to accomplish what you want.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Old 06-27-2007, 03:07 PM Re: Easy "report" function
Riane's Avatar
Super Talker

Latest Blog Post:
Happy Birthday, Steve!
Posts: 147
Name: Jordan
Location: Chicago, IL
Trades: 0
I've got a script that you can try out. Essentially what you're doing is setting up an .htaccess file, that will call to a php file that contains a script. This script will then send you the information in regards to the error that was received.

I haven't used this method in awhile, since my blog relies on a Wordpress Plugin that redirects to a customized 404 report page. Anyway:

Code:
<?php 
//choose the record either of the following statements 
//depending on what your host provides 
$file404 = $_SERVER['REDIRECT_ERROR_NOTES']."\n"; 
//or 
$file404 = $_SERVER['REDIRECT_URL'] . "\n"; 
$filename = '/var/users/mysite/htdocs/history404.txt'; 

if (file_exists($filename))  
{ 
    $filecontents = file($filename); 
    $add = (!in_array($file404, $filecontents)); 
} 
else $add = true; 

if ($add)  
{ 
    $fp = fopen($filename, 'a'); 
    $write = fputs($fp, $file404); 
    fclose($fp); 
    $body = ''; 
    $reportvars = array('REDIRECT_ERROR_NOTES','HTTP_HOST', 'HTTP_REFERER', 'HTTP_USER_AGENT', 'HTTP_FROM',  
        'REDIRECT_URL', 'REDIRECT_REQUEST_METHOD', 'REDIRECT_STATUS','REQUEST_URI','QUERY_STRING',  
        'REMOTE_ADDR', 'REMOTE_PORT'); 
    foreach($reportvars as $key) $body .= "$key: {$_SERVER[$key]}\n";  
    mail('webmaster@mysite.com','404:' . $_SERVER['REDIRECT_URL'],$body); 
} 

$revbits = explode('.',strrev($_SERVER['REDIRECT_URL'])); 

$pages['html'] = array('html','htm','php','txt'); 
$pages['special'] = array('css', 'js'); 

$ext = strrev($revbits[0]); 
if (in_array($ext, $pages['html'])) 
{ 
    // or show a make a comment form 
    header('Location: /index.php'); 
} 
elseif (in_array($ext, $pages['special'])) 
{ 
    //output nothing 
    echo ''; 
} 
else 
{ 
    //throw a large image onto the screen so it's easy to hunt down. 
    //change the width and height to a more discreet dimension when live 
    //although if the img has height and width attributes that will overrule 
    //the width and height here 
    $width = 50;  
    $height = 50;  

    $image  = ImageCreate($width,$height); 
    $blob = ImageColorAllocate($image,27,48,107); 

    if (function_exists("imagegif")) { 
        header ("Content-type: image/gif"); 
        imagegif ($image); 
    } 
    elseif (function_exists("imagejpeg")) { 
        header ("Content-type: image/jpeg"); 
        imagejpeg ($image, "", 0.5); 
    } 
    elseif (function_exists("imagepng")) { 
        header ("Content-type: image/png"); 
        imagepng ($image); 
    } 
    elseif (function_exists("imagewbmp")) { 
        header ("Content-type: image/vnd.wap.wbmp"); 
        imagewbmp ($image); 
    } 
    else 
        // or whatever action should be taken if you don't have GD installed. 
        die("No image support in this PHP server"); 

    ImageDestroy($image); 
} 
?>


To call the scripts add the following to your .htaccess file.

ErrorDocument 404 /track.php

You can name the file anything you want, so long as it contains the above code. You also have to make sure that you add other error codes to the htaccess file, unless you ONLY want to record missing links/pages that's being picked up.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

Riane is offline
Reply With Quote
View Public Profile Visit Riane's homepage!
 
Reply     « Reply to Easy "report" function
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.21565 seconds with 12 queries