Page blache

flague Messages postés 5 Date d'inscription mercredi 13 juin 2007 Statut Membre Dernière intervention 14 juin 2007 - 13 juin 2007 à 18:07
flague Messages postés 5 Date d'inscription mercredi 13 juin 2007 Statut Membre Dernière intervention 14 juin 2007 - 14 juin 2007 à 09:04
<?


  class padl
  {
    var $HASH_KEY1 = 'KD2bInfMjl9XDOsjx5qXn5Ax66w8frQi6I8QCOta';
    var $HASH_KEY2 = 'JZabr6I0aTYT6koV1a9D48zq90vXI1NKDYaqIQjx';
    var $HASH_KEY3 = 'kUfJBC90LUab7zhaznVxhcN1Tx5IiQ8SnEbiwHX6';
    var $HASH_KEY4 = 'LlvwQUIk71JSsq4O4d7DBkPq1Hk4fGAHUONc203e';
    var $ALGORITHM = 'blowfish';
    var $MODE = 'ecb';
    var $START_DIF = 129600;
    var $ID1 = '2G74V9SoLvSv55X22gZD';
    var $ID2 = 'ItaxScfhDGSvG7A7mlZW';
    var $ID3 = '49Zv4iNpr0MkW9JMIOBc';
    var $ID4 = '0RJLvtonC9d51I00KaB3';
    var $BEGIN1 = 'BEGIN LICENSE KEY';
    var $END1 = 'END LICENSE KEY';
    var $WRAPTO = 80;
    var $PAD = '-';
    var $BEGIN2 = '_DATA{';
    var $END2 = '}DATA_';
    var $FORCE_UPDATE = 0;
    var $DEBUG = true;
    var $REQUEST_MCRYPT = 0;
    var $REQUIRED_URIS = 2;
    var $DATE_STRING = 'd/M/Y H:i:s';
    var $RANDOM_SEED = 0;
    var $RANDOM_SEED_POS = 0;
    var $_DATA = array ();
    var $_SERVER_INFO = array ();
    var $_DAIL_HOST = '';
    var $_DAIL_PATH = '';
    var $_DAIL_PORT = 80;
    function padl ()
    {
      $this->_check_secure ();
    }


    function _get_os_linebreak ($true_val = false)
    {
      $os = strtolower (PHP_OS);
      switch ($os)
      {
        case 'freebsd':
        {
        }


        case 'netbsd':
        {
        }


        case 'solaris':
        {
        }


        case 'sunos':
        {
        }


        case 'linux':
        {
          $nl = '';
          break;
        }


        case 'darwin':
        {
          if ($true_val)
          {
            $nl = '';
          }
          else
          {
            $nl = '';
          }


          break;
        }


        default:
        {
          $nl = '';
        }
      }


      return $nl;
    }


    function _data_socket_connect ($host, $path, $query_array, $port = '80')
    {
      $this->_check_secure ();
      $query = 'POSTDATA=' . $this->_encrypt ($query_array, 'HOMEKEY') . '&QUERYTYPE=' . $this->call_type;
      $return = '';      $post_data array ('POSTDATA'> $this->_encrypt ($query_array, 'HOMEKEY'), 'QUERYTYPE' => $this->call_type, 'USE_MCRYPT' => $this->USE_MCRYPT, 'SCRIPT_URI' => $this->_SERVER_INFO['SCRIPT_URI']);
      $ssl = ($port != '80' ? 1 : 0);
      $PostMethod = 'fso';
      if (($ssl AND function_exists ('curl_init')))
      {
        $PostMethod = 'libCurlPost';
      }
      else
      {
        if (($ssl AND extension_loaded ('openssl')))
        {
          $PostMethod = 'fso';
        }
        else
        {
          $PostMethod = 'fso';
        }
      }


      switch ($PostMethod)
      {
        case 'libCurl':
        {
          $return = $this->_libCurlPost (($ssl ? 'https://' : 'http://') . $host . $path, $post_data);
          break;
        }


        case 'curl':
        {
          $return = $this->_curlPost (($ssl ? 'https://' : 'http://') . $host . $path, $post_data);
          break;
        }


        case 'fso':
        {
          $return = $this->_fsockPost (($ssl ? 'https://' : 'http://') . $host . $path, $post_data);
          break;
        }
      }


      $leftpos = strpos ($return, $this->BEGIN2) + strlen ($this->BEGIN2);
      $rightpos = strpos ($return, $this->END2) - $leftpos;
      $return = substr ($return, $leftpos, $rightpos);
      $return = $this->_decrypt ($return, 'HOMEKEY');
      return $return;
    }


    function _curlpost ($url, $data)
    {
      foreach ($data as $i => $v)
      {
        $postdata .= $i . '=' . urlencode ($v) . '&';
      }


      exec ('' . $curl_location . ' -d "' . $postdata . '" ' . $url, $info);
      $info = implode (',', $info);
      return $info;
    }


    function _libcurlpost ($url, $data)
    {
      foreach ($data as $i => $v)
      {
        $postdata .= $i . '=' . urlencode ($v) . '&';
      }


      $ch = curl_init ();
      curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
      curl_setopt ($ch, CURLOPT_URL, $url);
      curl_setopt ($ch, CURLOPT_POST, 1);
      curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
      ob_start ();
      curl_exec ($ch);
      $info = ob_get_contents ();
      curl_close ($ch);
      ob_end_clean ();
      return $info;
    }


    function _fsockpost ($url, $data)
    {
      $web = parse_url ($url);
      foreach ($data as $i => $v)
      {
        $postdata .= $i . '=' . urlencode ($v) . '&';
      }


      if ($web[scheme] == 'https')
      {
        $web[port] = '443';
        $ssl = 'ssl://';
      }
      else
      {
        $web[port] = '80';
      }


      $fp = @fsockopen ($ssl . $web[host], $web[port], $errnum, $errstr, 30);
      if (!$fp)
      {
        return '';
      }
      else
      {
        fputs ($fp, '' . 'POST ' . $web['path'] . ' HTTP/1.1');
        fputs ($fp, '' . 'Host: ' . $web['host'] . '');
        fputs ($fp, 'Content-type: application/x-www-form-urlencoded');
        fputs ($fp, 'Content-length: ' . strlen ($postdata) . '');
        fputs ($fp, 'Connection: close');
        fputs ($fp, $postdata . '');
        while (!feof ($fp))
        {
          $info[] = @fgets ($fp, 1024);
        }


        fclose ($fp);
        $info = implode (',', $info);
      }


      return $info;
    }


    function _compare_domain_ip ($domain, $ips = false)
    {
      if (!$ips)
      {
        $ips = $this->_get_ip_address ();
      }


      $domain_ips = gethostbynamel ($domain);
      if ((is_array ($domain_ips) AND 0 < count ($domain_ips)))
      {
        foreach ($domain_ips as $ip)
        {
          if ($ip == $ips)
          {
            return true;
            continue;
          }
        }
      }


      return false;
    }


    function _get_ip_address ()
    {
      $ips = array ();
      if (isset ($this->_SERVER_VARS['SERVER_NAME']))
      {
        $ip = gethostbyname ($this->_SERVER_VARS['SERVER_NAME']);
        if (!isset ($ips[$ip]))
        {
          $ips[$ip] = $ip;
        }
      }


      if (isset ($this->_SERVER_VARS['SERVER_ADDR']))
      {
        $name = gethostbyaddr ($this->_SERVER_VARS['SERVER_ADDR']);
        $ip = gethostbyname ($name);
        if (!isset ($ips[$ip]))
        {
          $ips[$ip] = $ip;
        }


        if ($ip != $this->_SERVER_VARS['SERVER_ADDR'])
        {
          if (!isset ($ips[$this->_SERVER_VARS['SERVER_ADDR']]))
          {
            $ips[$this->_SERVER_VARS['SERVER_ADDR']] = $this->_SERVER_VARS['SERVER_ADDR'];
          }
        }
      }


      if (0 < count ($ips))
      {
        reset ($ips);
        return current ($ips);
      }


      return 'IP_404';
    }


    function _pad ($str)
    {
      $str_len = strlen ($str);
      $spaces = ($this->WRAPTO - $str_len) / 2;
      $str1 = '';
      for ($i = 0; $i < $spaces; ++$i)
      {
        $str1 = $str1 . $this->PAD;
      }


      if ($spaces / 2 != round ($spaces / 2))
      {
        $str = substr ($str1, 0, strlen ($str1) - 1) . $str;
      }
      else
      {
        $str = $str1 . $str;
      }


      $str = $str . $str1;
      return $str;
    }


    function _get_key ($key_type)
    {
      switch ($key_type)
      {
        case 'KEY':
        {
          return $this->HASH_KEY1;
        }


        case 'REQUESTKEY':
        {
          return $this->HASH_KEY2;
        }


        case 'HOMEKEY':
        {
          return $this->HASH_KEY3;
        }


        case 'SERVERKEY':
        {
          return $this->HASH_KEY4;
        }
      }


    }


    function _get_begin ($key_type)
    {
      switch ($key_type)
      {
        case 'KEY':
        {
          return $this->BEGIN1;
        }


        case 'REQUESTKEY':
        {
          return $this->BEGIN2;
        }


        case 'HOMEKEY':
        {
          return '';
        }
      }


    }


    function _get_end ($key_type)
    {
      switch ($key_type)
      {
        case 'KEY':
        {
          return $this->END1;
        }


        case 'REQUESTKEY':
        {
          return $this->_END2;
        }


        case 'HOMEKEY':
        {
          return '';
        }
      }


    }


    function _generate_random_string ($length 10, $seeds 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890123456789')
    {
      $str = '';
      $seeds_count = strlen ($seeds);
      list ($usec, $sec) = explode (' ', microtime ());
      $seed = (double)$sec + (double)$usec * 100000;
      mt_srand ($seed);
      for ($i = 0; $i < $length; ++$i)
      {
        $str .= $seeds[mt_rand (0, $seeds_count - 1)];
      }


      return $str;
    }


    function _encrypt ($src_array, $key_type = 'KEY')
    {
      $this->_check_secure ();
      $this->USE_MCRYPT = $this->_validate_algorithm ();
      $rand_add_on = $this->_generate_random_string ($this->RANDOM_SEED);
      $key = $this->_get_key ($key_type);
      $key = $rand_add_on . $key;
      if ($this->USE_MCRYPT)
      {
        $str = serialize ($src_array);
        $Crypter = new Crypter ($this->HASH_KEY1);
        $crypt = $Crypter->encrypt ($str);
        $td = mcrypt_module_open ($this->ALGORITHM, '', $this->MODE, '');
        $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size ($td), MCRYPT_RAND);
        $key = substr ($key, 0, mcrypt_enc_get_key_size ($td));
        mcrypt_generic_init ($td, $key, $iv);
        $crypt = mcrypt_generic ($td, $crypt);
        mcrypt_generic_deinit ($td);
        mcrypt_module_close ($td);
      }
      else
      {
        $crypt = '';
        $str = serialize ($src_array);
        $Crypter = new Crypter ($this->HASH_KEY1 . $this->HASH_KEY2);
        $crypt = $Crypter->encrypt ($str);
      }


      return $rand_add_on . base64_encode (base64_encode ($crypt));
    }


    function _decrypt ($str, $key_type = 'KEY')
    {
      $this->_check_secure ();
      $this->USE_MCRYPT = $this->_validate_algorithm ();
      if (($this->REQUEST_MCRYPT AND $this->USE_MCRYPT))
      {
        $this->_trigger_error ('MCRYPT is not installed.');
      }


      $rand_add_on = substr ($str, 0, $this->RANDOM_SEED);
      $str = base64_decode (base64_decode (substr ($str, $this->RANDOM_SEED)));
      $key = $rand_add_on . $this->_get_key ($key_type);
      if ($this->USE_MCRYPT)
      {
        $td = mcrypt_module_open ($this->ALGORITHM, '', $this->MODE, '');
        $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size ($td), MCRYPT_RAND);
        $key = substr ($key, 0, mcrypt_enc_get_key_size ($td));
        mcrypt_generic_init ($td, $key, $iv);
        $decrypt = mdecrypt_generic ($td, $str);
        mcrypt_generic_deinit ($td);
        mcrypt_module_close ($td);
        $Crypter = new Crypter ($this->HASH_KEY1);
        $decrypt = $Crypter->decrypt ($decrypt);
      }
      else
      {
        $decrypt = '';
        $Crypter = new Crypter ($this->HASH_KEY1 . $this->HASH_KEY2);
        $decrypt = $Crypter->decrypt ($str);
      }


      return unserialize ($decrypt);
    }


    function _wrap_license ($src_array, $key_type = 'KEY')
    {
      $begin = $this->_pad ($this->_get_begin ($key_type));
      $end = $this->_pad ($this->_get_end ($key_type));
      $str = $this->_encrypt ($src_array, $key_type);
      return $begin . $this->_LINEBREAK . wordwrap ($str, $this->WRAPTO, $this->_LINEBREAK, 1) . $this->_LINEBREAK . $end;
    }


    function _unwrap_license ($enc_str, $key_type = 'KEY')
    {
      $begin = $this->_pad ($this->_get_begin ($key_type));
      $end = $this->_pad ($this->_get_end ($key_type));
      $str = trim (str_replace (array ($begin, $end, '', '', ' '), '', $enc_str));
      return $this->_decrypt ($str, $key_type);
    }


    function _check_secure ()
    {
      if (defined ('_PADL_REPORT_ABUSE_'))
      {
      }


      if (defined ('_PADL_MADE_SECURE_BY_PHP_LICENSER_'))
      {
        $this->_trigger_error ('PHP has been made secure.
You have attempted to use functions that have been protected and this has terminated the application.');
      }


    }


    function _trigger_error ($message, $fatal = true)
    {
    trigger_error ('

' . $message . '

', E_USER_ERROR);
      if ($fatal)
      {
        exit ();
      }


    }


    function _validate_algorithm ()
    {
      if (!function_exists ('mcrypt_module_open'))
      {
        return 0;
      }


      if (!in_array ($this->ALGORITHM, mcrypt_list_algorithms ()))
      {
        return 0;
      }


      if (!in_array ($this->MODE, mcrypt_list_modes ()))
      {
        return 0;
      }


      return 1;
    }
  }


  class crypter
  {
    function crypter ($clave)
    {
      $this->key = $clave;
    }


    function setkey ($clave)
    {
      $this->key = $clave;
    }


    function keyed ($txt)
    {
      $encrypt_key = md5 ($this->key);
      $ctr = 0;
      $tmp = '';
      for ($i = 0; $i < strlen ($txt); ++$i)
      {
        if ($ctr == strlen ($encrypt_key))
        {
          $ctr = 0;
        }


        $tmp .= substr ($txt, $i, 1) ^ substr ($encrypt_key, $ctr, 1);
        ++$ctr;
      }


      return $tmp;
    }


    function encrypt ($txt)
    {
      srand ((double)microtime () * 1000000);
      $encrypt_key = substr (md5 (rand (0, 32000)), 8, 16);
      $ctr = 0;
      $tmp = '';
      for ($i = 0; $i < strlen ($txt); ++$i)
      {
        if ($ctr == strlen ($encrypt_key))
        {
          $ctr = 0;
        }


        $tmp .= substr ($encrypt_key, $ctr, 1) . (substr ($txt, $i, 1) ^ substr ($encrypt_key, $ctr, 1));
        ++$ctr;
      }


      return base64_encode ($this->keyED ($tmp));
    }


    function decrypt ($txt)
    {
      $txt = $this->keyED (base64_decode ($txt));
      $tmp = '';
      for ($i = 0; $i < strlen ($txt); ++$i)
      {
        $md5 = substr ($txt, $i, 1);
        ++$i;
        $tmp .= substr ($txt, $i, 1) ^ $md5;
      }


      return $tmp;
    }
  }


  class license_application extends padl
  {
    var $HASH_KEY1 = 'KD2bInfMjl9XDOsjx5qXn5Ax66w8frQi6I8QCOta';
    var $HASH_KEY2 = 'JZabr6I0aTYT6koV1a9D48zq90vXI1NKDYaqIQjx';
    var $HASH_KEY3 = 'kUfJBC90LUab7zhaznVxhcN1Tx5IiQ8SnEbiwHX6';
    var $HASH_KEY4 = 'LlvwQUIk71JSsq4O4d7DBkPq1Hk4fGAHUONc203e';
    var $ALGORITHM = 'blowfish';
    var $MODE = 'ecb';
    var $START_DIF = 129600;
    var $ID1 = '2G74V9SoLvSv55X22gZD';
    var $ID2 = 'ItaxScfhDGSvG7A7mlZW';
    var $ID3 = '49Zv4iNpr0MkW9JMIOBc';
    var $ID4 = '0RJLvtonC9d51I00KaB3';
    var $BEGIN1 = 'BEGIN LICENSE KEY';
    var $END1 = 'END LICENSE KEY';
    var $WRAPTO = 80;
    var $PAD = '-';
    var $BEGIN2 = '_DATA{';
    var $END2 = '}DATA_';
    var $FORCE_UPDATE = 0;
    var $DEBUG = true;
    var $REQUEST_MCRYPT = 0;
    var $REQUIRED_URIS = 2;
    var $DATE_STRING = 'd/M/Y H:i:s';
    var $RANDOM_SEED = 0;
    var $RANDOM_SEED_POS = 0;
    var $_DATA = array ();
    var $_SERVER_INFO = array ();
    var $_DAIL_HOST = '';
    var $_DAIL_PATH = '';
    var $_DAIL_PORT = 80;
    var $ALLOWED_SERVER_DIFS = 0;
    var $CALL_HOME = true;
    function license_application ($license_path = 'license.dat')
    {
      $this->_check_secure ();
      $this->_LINEBREAK = $this->_get_os_linebreak ();
      $this->LICENSE_PATH = $license_path;
      $this->_MAC = $this->_get_mac_address ();
    }


    function set_dail_vars ($uri)
    {
      $param = array ();
      $param = parse_url ($uri);
      $this->_DAIL_HOST = $param['host'];
      $this->_DAIL_PATH = $param['path'];      $this->_DAIL_PORT ($param['scheme'] 'http' ? '80' : '443');
    }


    function set_server_vars ($array)
    {
      $this->_check_secure ();
      $this->_SERVER_VARS = $array;
      $this->_IPS = $this->_get_ip_address ();
      $this->_SERVER_INFO = $this->_get_server_info ();
    }


    function write_key ($key)
    {
      $this->_check_secure ();
      $h = @fopen ($this->LICENSE_PATH, 'w');
      if (@fwrite ($h, '<?/*' . $key . '*/' . '?' . '>') === false)
      {
        return false;
      }


      fclose ($h);
      return true;
    }


    function get_key ()
    {
      $this->_check_secure ();
      $lines = @file ($this->LICENSE_PATH);
      return trim (implode ('', @array_slice ($lines, 2, @count ($lines) - 4)));
    }


    function destroy_license ()
    {
      $this->_check_secure ();
      $h = @fopen ($this->LICENSE_PATH, 'a');
      @ftruncate ($h, 0);
      @fclose ($h);
    }


    function return_key_data ($str = false)
    {
      $this->_check_secure ();
      $dat_str = (!$str ? $this->get_key () : $str);
      if (0 < strlen ($dat_str))
      {
        return $this->_unwrap_license ($dat_str);
      }


      return false;
    }


    function view_license ($str = false)
    {
      $this->_check_secure ();
      $this->call_type = 'VALIDATE';
      $dat_str = (!$str ? $this->get_key () : $str);
      if (0 < strlen ($dat_str))
      {
        $data = $this->_unwrap_license ($dat_str);
        if (is_array ($data))
        {
          $id1 = md5 ($this->ID1);
          $id2 = md5 ($this->ID2);
          switch ($data['ID'])
          {
            case $id2:
            {
              $data['RESULT'] = 'PENDING';
              break;
            }


            case $id1:
            {
              break;
            }


            default:
            {
              $data['RESULT'] = 'CORRUPT';
            }
          }
        }
      }


      return $data;
    }


    function validate ($str false, $product 0, $simple_result = false)
    {
      $this->_check_secure ();
      $this->call_type = 'VALIDATE';
      $dat_str = (!$str ? $this->get_key () : $str);
      if (0 < strlen ($dat_str))
      {
        $data = $this->_unwrap_license ($dat_str);
        if (is_array ($data))
        {
          $id1 = md5 ($this->ID1);
          $id2 = md5 ($this->ID2);
          switch ($data['ID'])
          {
            case $id2:
            {
              $data['RESULT'] = 'PENDING';
              break;
            }


            case $id1:
            {
              break;
            }


            default:
            {
              $data['RESULT'] = 'CORRUPT';
            }
          }


          if ($data['PRODUCT'] != $product)
          {
            $data['RESULT'] = 'PRODUCT_MISMATCH';
          }


          if ($data['BINDING']['DATE'])
          {
            if (time () + $this->START_DIF < $data['DATE']['START'])
            {
              $data['RESULT'] = 'DATE_MISMATCH';
            }


            if (($data['DATE']['END'] - time () < 0 AND $data['DATE']['SPAN'] != 'NEVER'))
            {
              $data['RESULT'] = 'DATE_MISMATCH';
            }


            $data['DATE']['HUMAN']['START'] = @date ($this->DATE_STRING, $data['DATE']['START']);
            $data['DATE']['HUMAN']['END'] = @date ($this->DATE_STRING, $data['DATE']['END']);
          }


          if ($data['BINDING']['SERVER'])
          {            $os $data['SERVER']['OS'] PHP_OS;            $mac $data['SERVER']['MAC'] $this->_MAC;
            if ((!$os OR !$mac))
            {
              $data['RESULT'] = 'ILLEGAL_MAC';
            }
          }


          if ($data['BINDING']['PATH'])
          {            $path $this->_SERVER_INFO['INSTALL_PATH'] $data['SERVER']['PATH'];
            if (!$path)
            {
              $data['RESULT'] = 'ILLEGAL_PATH';
            }
          }


          if ($data['BINDING']['DOMAIN'])
          {            $license_domain (strtolower (substr ($data['SERVER']['DOMAIN'], 0, 4)) 'www.' ? substr ($data['SERVER']['DOMAIN'], 4) : $data['SERVER']['DOMAIN']);            $server_domain (strtolower (substr ($this->_SERVER_VARS['HTTP_HOST'], 0, 4)) 'www.' ? substr ($this->_SERVER_VARS['HTTP_HOST'], 4) : $this->_SERVER_VARS['HTTP_HOST']);            $domain $license_domain $server_domain;
            $valid_domain = $this->_compare_domain_ip ($data['SERVER']['DOMAIN'], $this->_IPS);
            if ((!$valid_domain OR !$domain))
            {
              $data['RESULT'] = 'ILLEGAL_DOMAIN';
            }
          }


          if ($data['BINDING']['IP'])
          {            $ip $this->_IPS $data['SERVER']['IP'];
            if (!$ip)
            {
              $data['RESULT'] = 'ILLEGAL_IP';
            }
          }


          if (!$data['BINDING']['LOCAL'])
          {            $local (('127.0.0.1' $this->_IPS OR $this->_SERVER_INFO['SERVER_ADDR'] == '127.0.0.1') OR $this->_SERVER_INFO['HTTP_HOST'] == '127.0.0.1');
            if ($local)
            {
              $data['RESULT'] = 'ILLEGAL_LOCAL';
            }
          }


          if (($data['BINDING']['REMOTE'] AND (($data['RESULT'] == 'PENDING' OR $data['CALLSPAN'] <= time () - $data['LASTCALL']) OR $this->FORCE_UPDATE == 1)))
          {
            $stuff_to_send = array ();
            $stuff_to_send['LICENSE_DATA'] = $data;
            $stuff_to_send['LICENSE_DATA']['KEY'] = md5 ($dat_str);
            $RESULT = $this->_call_home ($stuff_to_send, $this->_DAIL_HOST, $this->_DAIL_PATH, $this->_DAIL_PORT);
            if (is_array ($RESULT))
            {
              $data['UPDATE_KEY'] = $RESULT['UPDATE_KEY'];
              $data['CUSTOM'] = $RESULT['CUSTOM'];
              if ((!isset ($data['RESULT']) OR $data['RESULT'] == 'PENDING'))
              {
                $data['RESULT'] = $RESULT['RESULT'];
              }


              if ($RESULT['RESULT'] == 'LICENSE_UPDATED')
              {
                $data['RESULT'] = 'LICENSE_UPDATED';
              }
            }
            else
            {
              if ((!isset ($data['RESULT']) OR $data['RESULT'] != 'PENDING'))
              {
                $data['RESULT'] = $RESULT;
              }


              if ($RESULT == 'LICENSE_UPDATED')
              {
                $data['RESULT'] = 'LICENSE_UPDATED';
              }
            }
          }
          else
          {
            if (!isset ($data['RESULT']))
            {
              $data['RESULT'] = 'OK';
            }
          }


          if ($simple_result)
          {            $data ($data['RESULT'] 'OK' ? true : false);
          }


          return $data;
        }
        else
        {
          return ($simple_result ? false : array ('RESULT' => 'INVALID'));
        }
      }


      return ($simple_result ? false : array ('RESULT' => 'EMPTY'));
    }


    function query_license ($keycode, $product, $local_key = false)
    {
      $this->_check_secure ();
      $this->call_type = 'VALIDATE';
      $data = array ();
      if ((count ($this->_SERVER_INFO) < $this->REQUIRED_URIS AND $bind_to_server))
      {
        return array ('RESULT' => 'SERVER_FAIL');
      }


      if (!$this->_compare_domain_ip ($this->_SERVER_INFO['HTTP_HOST'], $this->_IPS))
      {
        return array ('RESULT' => 'DOMAIN_IP_FAIL');
      }


      $data['ID'] = md5 ($this->ID4);
      $data['KEYCODE'] = $keycode;
      $data['PRODUCT'] = $product;
      $data['SERVER']['IP'] = $this->_IPS;
      $data['SERVER']['DOMAIN'] = $this->_SERVER_INFO['HTTP_HOST'];
      $data['SERVER']['MAC'] = $this->_MAC;
      $data['SERVER']['OS'] = PHP_OS;
      $data['SERVER']['PATH'] = $this->_SERVER_INFO['INSTALL_PATH'];
      $other['_PHP_VERSION'] = PHP_VERSION;
      $data['DATA'] = $other;
      $key = $this->_wrap_license ($data);
      $stuff_to_send = array ();
      $stuff_to_send['LICENSE_DATA'] = $data;
      $stuff_to_send['LICENSE_DATA']['KEY'] = md5 ($key);
      $RESULT = $this->_call_home ($stuff_to_send, $this->_DAIL_HOST, $this->_DAIL_PATH, $this->_DAIL_PORT);
      $data['UPDATE_KEY'] = $RESULT['UPDATE_KEY'];
      $data['CUSTOM'] = $RESULT['CUSTOM'];
      $data['RESULT'] = $RESULT['RESULT'];
      return $data;
    }


    function make_secure ($report = false)
    {
      if ($report)
      {
        define ('_PADL_REPORT_ABUSE_', true);
      }


      foreach (array_keys (get_object_vars ($this)) as $value)
      {
        unset ($this[$value]);
      }


      define ('_PADL_MADE_SECURE_BY_PHP_LICENSER_', 1);
    }


    function _get_os_var ($var_name, $os)
    {
      $var_name = strtolower ($var_name);
      switch ($os)
      {
        case 'freebsd':
        {
        }


        case 'netbsd':
        {
        }


        case 'solaris':
        {
        }


        case 'sunos':
        {
        }


        case 'darwin':
        {
          switch ($var_name)
          {
            case 'conf':
            {
              return '/sbin/ifconfig';
            }


            case 'mac':
            {
              return 'ether';
            }


            case 'ip':
            {
              return 'inet ';
            }
          }


          break;
        }


        case 'linux':
        {
          switch ($var_name)
          {
            case 'conf':
            {
              return '/sbin/ifconfig';
            }


            case 'mac':
            {
              return 'HWaddr';
            }


            case 'ip':
            {
              return 'inet addr:';
            }
          }


          break;
        }
      }


      return false;
    }


    function _get_config_file ()
    {
      $this->_check_secure ();
      if (ini_get ('safe_mode'))
      {
        return 'SAFE_MODE';
      }


      $os = strtolower (PHP_OS);
      if (substr ($os, 0, 3) == 'win')
      {
        @exec ('ipconfig/all', $lines);
        if (count ($lines) == 0)
        {
          return 'ERROR_OPEN';
        }


        $conf = implode ($this->_LINEBREAK, $lines);
      }
      else
      {
        $os_file = $this->_get_os_var ('conf', $os);
        $fp = @popen ($os_file, 'rb');
        if (!$fp)
        {
          return 'ERROR_OPEN';
        }


        $conf = @fread ($fp, 4096);
        @pclose ($fp);
      }


      return $conf;
    }


    function _get_mac_address ()
    {
      $conf = $this->_get_config_file ();
      $os = strtolower (PHP_OS);
      if (substr ($os, 0, 3) == 'win')
      {
        $lines = explode ($this->_LINEBREAK, $conf);
        foreach ($lines as $key => $line)
        {
          if (preg_match ('/([0-9a-f][0-9a-f][-:]){5}([0-9a-f][0-9a-f])/i', $line))
          {
            $trimmed_line = trim ($line);
            return trim (substr ($trimmed_line, strrpos ($trimmed_line, ' ')));
            continue;
          }
        }
      }
      else
      {
        $mac_delim = $this->_get_os_var ('mac', $os);
        $pos = strpos ($conf, $mac_delim);
        if ($pos)
        {
          $str1 = trim (substr ($conf, $pos + strlen ($mac_delim)));
          return trim (substr ($str1, 0, strpos ($str1, '')));
        }
      }


      return 'MAC_404';
    }


    function _get_server_info ()
    {
      if (empty ($this->_SERVER_VARS))
      {
        $this->set_server_vars ($_SERVER);
      }


      $data = array ();
      $data['SCRIPT_DIR'] = dirname ('E:\\classes\\phplicencer\\license_class\\app.php');
      if (isset ($this->_SERVER_VARS['SERVER_ADDR']))
      {
        $data['SERVER_ADDR'] = $this->_SERVER_VARS['SERVER_ADDR'];
      }


      if (isset ($this->_SERVER_VARS['HTTP_HOST']))
      {
        $data['HTTP_HOST'] = (strtolower (substr ($this->_SERVER_VARS['HTTP_HOST'], 0, 4)) == 'www.' ? substr ($this->_SERVER_VARS['HTTP_HOST'], 4) : $this->_SERVER_VARS['HTTP_HOST']);
      }


      if (isset ($this->_SERVER_VARS['SERVER_NAME']))
      {
        $data['SERVER_NAME'] = $this->_SERVER_VARS['SERVER_NAME'];
      }


      if (isset ($this->_SERVER_VARS['PATH_TRANSLATED']))
      {
        $data['PATH_TRANSLATED'] = $data['INSTALL_PATH'] = substr ($this->_SERVER_VARS['PATH_TRANSLATED'], 0, strrpos ($this->_SERVER_VARS['PATH_TRANSLATED'], '/'));
      }
      else
      {
        if (isset ($this->_SERVER_VARS['SCRIPT_FILENAME']))
        {
          $data['SCRIPT_FILENAME'] = $data['INSTALL_PATH'] = substr ($this->_SERVER_VARS['SCRIPT_FILENAME'], 0, strrpos ($this->_SERVER_VARS['SCRIPT_FILENAME'], '/'));
        }
      }


      if (isset ($_SERVER['SCRIPT_URI']))
      {
        $data['SCRIPT_DIR_URI'] = substr ($this->_SERVER_VARS['SCRIPT_URI'], 0, strrpos ($this->_SERVER_VARS['SCRIPT_URI'], '/'));
      }


      if (isset ($_SERVER['PHP_SELF']))
      {
        $data['SCRIPT_URI'] = $this->_SERVER_VARS['HTTP_HOST'] . $this->_SERVER_VARS['PHP_SELF'];
      }
      else
      {
        if (isset ($_SERVER['SCRIPT_NAME']))
        {
          $data['SCRIPT_URI'] = $this->_SERVER_VARS['HTTP_HOST'] . $this->_SERVER_VARS['SCRIPT_NAME'];
        }
        else
        {
          if (isset ($_SERVER['REQUEST_URI']))
          {
            $data['SCRIPT_URI'] = $this->_SERVER_VARS['HTTP_HOST'] . $this->_SERVER_VARS['REQUEST_URI'];
          }
        }
      }


      if ($this->_SERVER_VARS['HTTP_USER_AGENT'] == 'PHPLICENSER')
      {
        $this->FORCE_UPDATE = 1;
      }


      if (count (array_unique ($data)) < $this->REQUIRED_URIS)
      {
        return 'SERVER_FAILED';
      }


      return $data;
    }


    function _call_home ($data, $dialhost, $dialpath, $dialport)
    {
      $data = $this->_data_socket_connect ($dialhost, $dialpath, $data, $dialport);
      return (empty ($data['RESULT']) ? 'SOCKET_FAILED' : $data);
    }
  }


  class license_architect extends license_application
  {
    var $HASH_KEY1 = 'KD2bInfMjl9XDOsjx5qXn5Ax66w8frQi6I8QCOta';
    var $HASH_KEY2 = 'JZabr6I0aTYT6koV1a9D48zq90vXI1NKDYaqIQjx';
    var $HASH_KEY3 = 'kUfJBC90LUab7zhaznVxhcN1Tx5IiQ8SnEbiwHX6';
    var $HASH_KEY4 = 'LlvwQUIk71JSsq4O4d7DBkPq1Hk4fGAHUONc203e';
    var $ALGORITHM = 'blowfish';
    var $MODE = 'ecb';
    var $START_DIF = 129600;
    var $ID1 = '2G74V9SoLvSv55X22gZD';
    var $ID2 = 'ItaxScfhDGSvG7A7mlZW';
    var $ID3 = '49Zv4iNpr0MkW9JMIOBc';
    var $ID4 = '0RJLvtonC9d51I00KaB3';
    var $BEGIN1 = 'BEGIN LICENSE KEY';
    var $END1 = 'END LICENSE KEY';
    var $WRAPTO = 80;
    var $PAD = '-';
    var $BEGIN2 = '_DATA{';
    var $END2 = '}DATA_';
    var $FORCE_UPDATE = 0;
    var $DEBUG = true;
    var $REQUEST_MCRYPT = 0;
    var $REQUIRED_URIS = 2;
    var $DATE_STRING = 'd/M/Y H:i:s';
    var $RANDOM_SEED = 0;
    var $RANDOM_SEED_POS = 0;
    var $_DATA = array ();
    var $_SERVER_INFO = array ();
    var $_DAIL_HOST = '';
    var $_DAIL_PATH = '';
    var $_DAIL_PORT = 80;
    var $ALLOWED_SERVER_DIFS = 0;
    var $CALL_HOME = true;
    function license_architect ($license_path = 'license.dat')
    {
      $this->_check_secure ();
      $this->_LINEBREAK = $this->_get_os_linebreak ();
      $this->license_application ($license_path);
    }


    function set_register_account ($username, $password)
    {
      $this->register_username = $username;
      $this->register_password = $password;
    }


    function register_install ($keycode, $product, $other = array ())
    {
      $this->_check_secure ();
      $this->call_type = 'REGISTER';
      $domain = $this->_SERVER_INFO['HTTP_HOST'];
      if (empty ($keycode))
      {
        return array ('RESULT' => 'KEYCODE_404');
      }


      if (empty ($domain))
      {
        return array ('RESULT' => 'DOMAIN_404');
      }


      if (4 < @filesize ($this->LICENSE_PATH))
      {
        return array ('RESULT' => 'KEY_EXISTS');
      }


      if (!$this->_compare_domain_ip ($domain, $this->_IPS))
      {
        return array ('RESULT' => 'DOMAIN_IP_FAIL');
      }


      $data = array ();
      $data['ID'] = md5 ($this->ID3);
      $data['USERNAME'] = $this->register_username;
      $data['PASSWORD'] = $this->register_password;
      $data['KEYCODE'] = $keycode;
      $data['PRODUCT'] = $product;
      $data['SERVER']['OS'] = PHP_OS;
      $data['SERVER']['DOMAIN'] = $domain;
      $data['SERVER']['IP'] = $this->_IPS;
      $data['SERVER']['MAC'] = $this->_MAC;
      $data['SERVER']['PATH'] = $this->_SERVER_INFO['INSTALL_PATH'];
      $other['_PHP_VERSION'] = PHP_VERSION;
      $data = $this->_data_socket_connect ($this->_DAIL_HOST, $this->_DAIL_PATH, $data, $this->_DAIL_PORT);
      return (empty ($data['RESULT']) ? array ('RESULT' => 'SOCKET_FAILED') : $data);
    }


    function _generate_keycode ($sep = '-')
    {
      $str = $this->_generate_random_string (16, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678901234567890');
      return substr ($str, 0, 4) . $sep . substr ($str, 4, 4) . $sep . substr ($str, 8, 4) . $sep . substr ($str, 12, 4);
    }
  }


  function trace ()
  {
    $message = '';
    for ($i = 0; $i < func_num_args (); ++$i)
    {
      if (is_array (func_get_arg ($i)))
      {
        trace_r (func_get_arg ($i));
      }
      else
      {
        $message .= func_get_arg ($i);
      }


      if ($i <= func_num_args () - 2)
      {
        $message .= ' : ';
        continue;
      }
    }


    echo '
' . $message . ' ';
  }


  function trace_r ($array = 'array is empty')
  {
    echo '';
    print_r ($array);
    echo '

';
  }


?>

3 réponses

flague Messages postés 5 Date d'inscription mercredi 13 juin 2007 Statut Membre Dernière intervention 14 juin 2007
13 juin 2007 à 18:11
Se fichier me revois des information concernant le serveur distant : la clé l'IP HOST PATCH etc.... mais il ne me renvois rien merci pour vos réponse.

PS : j'utilise :

APACHE_VER=1.3.37
MODSSL_VER=2.8.28
PHP_VER=4.4.7
CURL_VER=7.16.2
MHASH_VER=0.9.1
0
cs_corsica Messages postés 147 Date d'inscription lundi 13 mai 2002 Statut Membre Dernière intervention 15 février 2010
14 juin 2007 à 08:50
Tu crées des classes avec des fonctions ... OK ...
Mais tu les instancies quand ?
Et tu les utilises quand ?
Le code que tu nous montres fait des tas de trucs mais si tu n'appelles jamais les fonctions alors effectivement ta page sera blanche.






<hr />


Life is Too Short ...
Enjoy Your Life ...
0
flague Messages postés 5 Date d'inscription mercredi 13 juin 2007 Statut Membre Dernière intervention 14 juin 2007
14 juin 2007 à 09:04
Bonjour, se fichier est sur le serveur distant, il dialogue avec mon script qui lui se trouve sur mon serveur. Il crée des clés et renvois les informations HTP IP DOMAINE PATCH


Sur mon serveur. Si tout est bon le script qui utilise se fichier est ok . mais si il renvois des informations négative, il redirige le script distant sur une page de mon serveur indiquant que la clé ou le domaine n’est pas bon .
0