Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2014
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.93 KB | None | 0 0
  1. <?php
  2.  
  3. class TrustedShop {
  4.  
  5.   const ServiceHost = 'www.arukereso.hu';
  6.  
  7.   const ServiceUrl = '/affiliation/TrustedShop.php';
  8.  
  9.   const ErrorEmail = 'Nem adta meg a vasarlo email cimet';
  10.  
  11.   const ErrorService = 'Nem sikerult menteni a vasarlo adatait.';
  12.  
  13.   private $WebApiKey;
  14.  
  15.   private $Email;
  16.  
  17.   private $Products = array();
  18.  
  19.   private $Protocol;
  20.  
  21.   public function __construct($WebApiKey) {
  22.     $this->WebApiKey = $WebApiKey;
  23.     $this->Protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') ? 'https' : 'http';
  24.   }
  25.  
  26.   public function SetEmail($Email) {
  27.     $this->Email = $Email;
  28.   }
  29.  
  30.   public function AddProduct($ProductName) {
  31.     $this->Products[] = $ProductName;
  32.   }
  33.  
  34.   public function Send() {
  35.     if (empty($this->Email)) {
  36.       throw new Exception(self::ErrorEmail);
  37.     }
  38.    
  39.     $String = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
  40.     $C = '';
  41.     for ($i = 0; $i < 20; $i++) {
  42.       $C .= $String{mt_rand(0, strlen($String) - 1)};
  43.     }
  44.    
  45.     $Timestamp = time();
  46.     $HashedKey = md5($this->WebApiKey . $Timestamp);
  47.  
  48.     $Query = 'HashedKey=' . $HashedKey . '&Email=' . urlencode($this->Email);
  49.     foreach ($this->Products as $ProductName) {
  50.       $Query .= '&Products[]=' . urlencode($ProductName);
  51.     }
  52.     $Query .= '&Timestamp=' . $Timestamp;
  53.    
  54.     echo '<script type="text/javascript" src="' . $this->Protocol . '://' . self::ServiceHost . '/fc.js"></script>';
  55.     echo
  56.       '<script type="text/javascript">',
  57.       'function fc_request_done(C) { var I = new Image(); I.src=\'' . $this->Protocol . '://' . self::ServiceHost . self::ServiceUrl . "?" . $Query . '&C=\'+C; }',
  58.       'set_fc("' . self::ServiceHost . '", "__aku","' . $C . '");',
  59.       '</script>';
  60.    
  61.     echo
  62.       '<noscript>',
  63.       '<img src="' . $this->Protocol . '://' . self::ServiceHost . self::ServiceUrl . "?" . $Query . '&C=' . $C . '">',
  64.       '</noscript>';
  65.   }
  66. }
  67.  
  68. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement