SetHeaders();
$this->GrabAndSetupVars();
$this->Musa_generatingEmailTemplate();
$this->MusaSendEmailToAdmin();
}
public function SetHeaders()
{
$Current_theme_info = wp_get_theme();
$TextDomain = $Current_theme_info->get( 'TextDomain' );
echo header(__('HTTP/1.1 404 Not Found',$TextDomain));
echo header(__('Status: 404 Not Found',$TextDomain));
}
function GrabAndSetupVars()
{
$this->siteURL = home_url( '/' );
$this->emailTo = get_bloginfo( 'admin_email' );
/* Server and execution environment information:
* */
// Server request URI
$this->requestURI = isset( $_SERVER['REQUEST_URI'] ) && isset( $_SERVER['HTTP_HOST'] ) ? $this->Musa_QueryString( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ) : 'unknown';
// Server query string
$this->queryString = isset( $_SERVER['QUERY_STRING'] ) ? $this->Musa_QueryString( $_SERVER['QUERY_STRING'] ) : 'unknown';
// Server IP address
$this->remoteAddressIP = isset( $_SERVER['REMOTE_ADDR'] ) ? $this->Musa_QueryString( $_SERVER['REMOTE_ADDR'] ) : 'unknown';
// User agent
$this->httpUserAgent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $this->Musa_QueryString( $_SERVER['HTTP_USER_AGENT'] ) : 'unknown';
// Log Time
$this->searchingTime = $this->Musa_QueryString(date_i18n( get_option( 'date_format' ), strtotime( "F jS Y, h:i A") ));
}
public function Musa_QueryString( $string )
{
$string = rtrim( $string );
$string = ltrim( $string );
$string = htmlentities( $string, ENT_QUOTES );
$string = str_replace( "\n", "
", $string );
if ( get_magic_quotes_gpc() ) {
$string = stripslashes( $string );
}
return $string;
}
// Generate Email Template with regurding data
public function Musa_generatingEmailTemplate()
{
$this->SendingMessagesInfo = '
Hi This is 404 Not Found Error Keeper,
Just Few While Ago Someone try to search something on your '.$this->siteURL.' this site.
And I Found 404 Not Found Error According to this Keyword '.$this->queryString.'.
Please Check this Keyword like =" or "=" ,1=1 this SQL Injection ,then Improve your site security.
OR Keyword is match on your website context then improve your content.
Have a look on full details about this below.
| Element | Information |
|---|---|
| Searching Time | '.$this->searchingTime.' |
| 404 URL | '.$this->requestURI.' |
| Website URL | '.$this->siteURL.' |
| Search Keyword | '.$this->queryString.' |
| Visitor IP | '.$this->remoteAddressIP.' |
| User Agent | '.$this->httpUserAgent.' |
This email is generated by 404 search to email plugins form your site.
'; } // Email Header Information public function emailHeaderInfo() { return sprintf( 'From: %s ' . "\r\n" . 'MIME-Version: 1.0' . "\r\n" . 'Content-Type: text/html; charset=ISO-8859-1' . "\r\n", 'no-reply@webmaster.com' ); } // Email Send public function MusaSendEmailToAdmin() { add_filter('wp_mail_content_type',create_function('', 'return "text/html"; ')); if($_REQUEST['s']!=''){ wp_mail( $this->emailTo, 'Head UP Please!', $this->SendingMessagesInfo, sprintf( 'From: %s ', $this->emailHeaderInfo() ) ); } } } } //object creatign and hook into pluglabe api. function Musa_Push_QueryString_Info_Admin() { return new MusaFetch_404_QueryStringToEmail_Admin(); }