[ Index ]

MailPress 7.1

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]     [ Statistics ]    

title

Body

[close]

/mp-includes/class/ -> MP_Tracking.class.php (source)

   1  <?php
   2  class MP_Tracking
   3  {
   4  	public static function process()
   5      {
   6          $get_ = filter_input_array( INPUT_GET );
   7  
   8          $meta = MP_Mail_meta::get_by_id( $get_['mm'] );
   9          if ( $meta )
  10          {
  11              do_action( 'mp_tracking_process', $meta ); // will activate if any !
  12              switch ( $get_['tg'] )
  13              {
  14                  case ( 'l' ) :
  15                      switch ( $meta->meta_value )
  16                      {
  17                          case '{{subscribe}}' :
  18                              $url = MP_User::get_subscribe_url( $get_['us'] );
  19                          break;
  20                          case '{{unsubscribe}}' :
  21                              $url = MP_User::get_unsubscribe_url( $get_['us'] );
  22                          break;
  23                          case '{{viewhtml}}' :
  24                              $url = MP_User::get_view_url( $get_['us'], $meta->mp_mail_id );
  25                          break;
  26                          default :
  27                              $pattern = '#^(http|https)://[\w-]+[\w.-]+\.[a-zA-Z]{2,6}#i';
  28                              $url = false;
  29                              foreach( array( $meta->meta_value, 'https://' . $meta->meta_value ) as $u ) if ( preg_match( $pattern, $u ) ) $url = $u;
  30                              if ( !$url ) $url = $meta->meta_value;
  31                          break;
  32                      }
  33                      MP_::mp_redirect( $url );
  34                  break;
  35                  case ( 'o' ) :
  36                      self::download( '_.gif', MP_ABSPATH . 'mp-includes/images/_.gif', 'image/gif', 'gif_' . $get_['us'] . '_' . $get_['mm'] . '.gif' );
  37                  break;
  38              }
  39          }
  40          MP_::mp_redirect( home_url() );
  41      }
  42  
  43  	public static function download( $file, $file_fullpath, $mime_type, $name = false )
  44      {
  45          if ( !$name ) $name = $file;
  46  
  47          $HTTP_USER_AGENT = filter_input( INPUT_SERVER, 'HTTP_USER_AGENT' );
  48          if ( strstr( $HTTP_USER_AGENT, 'MSIE' ) ) $file = preg_replace( '/\./', '%2e', $file, substr_count( $file, '.' ) - 1 );
  49  
  50          if( !$fdl = @fopen( $file_fullpath, 'r' ) )     MP_::mp_die( __( 'Cannot Open File !', 'MailPress' ) );
  51  
  52          header( "Cache-Control: " );# leave blank to avoid IE errors
  53          header( "Pragma: " );# leave blank to avoid IE errors
  54          header( "Content-type: " . $mime_type );
  55          header( "Content-Disposition: attachment; filename=\"".$file."\"" );
  56          header( "Content-length:".( string )( filesize( $file_fullpath ) ) );
  57          sleep( 1 );
  58          fpassthru( $fdl );
  59          MP_::mp_die();
  60      }
  61  }


Generated: Mon Mar 11 18:33:33 2019 Cross-referenced by PHPXref 0.7.1