Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2014
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.78 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by deZender.Net
  5. * @ deZender (PHP5 Decoder for SourceGuardian & phpSHIELD)
  6. *
  7. * @ Version : 1.1.6.0
  8. * @ Author : DeZender
  9. * @ Release on : 02.06.2013
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14. /**
  15. * Licensing Class.
  16. *
  17. * @author Andy Rockwell <andy@solidphp.com>
  18. */
  19. class licensing {
  20. /**
  21. * Validate licensing
  22. *
  23. * @param string $api_fingerprint
  24. * @param string $server
  25. * @param string $RPC
  26. * @param string $license
  27. * @return mixed string on error; array on success
  28. */
  29. static public function validate_license($api_fingerprint, $server, $RPC, $license) {
  30. $returned = licensing::parse_xml( licensing::validate_local_key( ) );
  31.  
  32. if (( $returned['status'] == 'grab_new_key' || $returned['status'] == 'expired' )) {
  33. $returned = licensing::parse_xml( licensing::go_remote( $method, $server, $license ) );
  34.  
  35. if (empty( $returned )) {
  36. $returned['status'] = 'invalid';
  37. }
  38.  
  39. licensing::go_remote_api( $RPC, $api_fingerprint, $license );
  40. $returned = licensing::parse_xml( licensing::validate_local_key( true ) );
  41. }
  42.  
  43.  
  44. if (( $returned['status'] != 'active' && $returned['status'] != 'reissued' )) {
  45. if (empty( $returned )) {
  46. $returned['status'] = 'invalid';
  47. }
  48.  
  49. $errors = false;
  50.  
  51. if ($returned['status'] == 'suspended') {
  52. $errors = 'This license has been suspended.';
  53. } else {
  54. if ($returned['status'] == 'pending') {
  55. $errors = 'This license is pending admin approval.';
  56. } else {
  57. if ($returned['status'] == 'expired') {
  58. $errors = 'This license is expired.';
  59. } else {
  60. if ($returned['status'] == 'renew') {
  61. $errors = $returned['message'];
  62. } else {
  63. if (( $returned['status'] == 'active' && strcmp( md5( 'a666d67aae067313345c74abd7b666b0' . $token ), $returned['access_token'] ) != 0 )) {
  64. $errors = 'This license has an invalid checksum.';
  65. } else {
  66. if (!empty( $errors )) {
  67. $errors = false;
  68. }
  69.  
  70. $errors = 'This license appears to be invalid.';
  71. }
  72. }
  73. }
  74. }
  75. }
  76. }
  77.  
  78.  
  79. if (!empty( $errors )) {
  80. $errors = false;
  81. }
  82.  
  83. return ($errors ? $errors : $returned);
  84. }
  85.  
  86. /**
  87. * Write the local license key to somewhere.
  88. *
  89. * @param string $local_key The local key data to write.
  90. * @return You choose.
  91. */
  92. static public function store_local_key($local_key) {
  93. $count = mysql_fetch_row( mysql_query( 'select count(*) from settings where set_name=\'license_local_key\'' ) );
  94. $query = 'update settings set set_value=\'' . $local_key . '\' where set_name=\'license_local_key\'';
  95.  
  96. if (!$count[0]) {
  97. $query = ( 'insert into settings set set_name=\'license_local_key\', set_value=\'' . $local_key . '\'' );
  98. }
  99.  
  100. return mysql_query( $query );
  101. }
  102.  
  103. /**
  104. * Get the local key from where you stored it.
  105. *
  106. * @return string The local license key.
  107. */
  108. public function get_stored_local_key() {
  109. $local_key = mysql_fetch_assoc( mysql_query( 'select set_value from settings where set_name=\'license_local_key\' limit 0, 1' ) );
  110. return $local_key['set_value'];
  111. }
  112.  
  113. /**
  114. * Write the best remote licensing method
  115. *
  116. * @param string $method Either phpaudit_exec_socket, phpaudit_exec_curl or file_get_contents
  117. * @return You choose.
  118. */
  119. static public function write_best_method($method) {
  120. $count = mysql_fetch_row( @mysql_query( 'select count(*) from settings where set_name=\'license_method\'' ) );
  121. $query = 'update settings set set_value=\'' . $method . '\' where set_name=\'license_method\'';
  122.  
  123. if (!$count[0]) {
  124. $query = ( 'insert into settings set set_name=\'license_method\', set_value=\'' . $method . '\'' );
  125. }
  126.  
  127. return mysql_query( $query );
  128. }
  129.  
  130. /**
  131. * Get the best remote licensing method previously saved
  132. *
  133. * @return string The saved or default remote call method.
  134. */
  135. public function get_best_method() {
  136. $method = mysql_fetch_assoc( mysql_query( 'select set_value from settings where set_name=\'license_method\'' ) );
  137.  
  138. if ($method['set_value']) {
  139. return $method['set_value'];
  140. }
  141.  
  142. return 'phpaudit_exec_socket';
  143. }
  144.  
  145. /**
  146. * Validate a local license key
  147. *
  148. * @return boolean $debug
  149. * @return array The results of validation.
  150. */
  151. static public function validate_local_key($debug = false) {
  152. $raw_array = licensing::parse_local_key( );
  153.  
  154. if (( !@is_array( $raw_array ) || $raw_array === false )) {
  155. return '<verify status=\'grab_new_key\' message=\'The local license key was empty.\' />';
  156. }
  157.  
  158.  
  159. if (( $raw_array[9] && strcmp( @md5( 'a666d67aae067313345c74abd7b666b0' . $raw_array[9] ), $raw_array[10] ) != 0 )) {
  160. return '<verify status=\'invalid\' message=\'The custom variables were tampered with.\' />';
  161. }
  162.  
  163.  
  164. if (strcmp( @md5( 'a666d67aae067313345c74abd7b666b0' . $raw_array[1] ), $raw_array[2] ) != 0) {
  165. return '<verify status=\'invalid\' message=\'The local license key checksum failed.\' ' . $raw_array[9] . ' />';
  166. }
  167.  
  168.  
  169. if (( $raw_array[1] < time( ) && $raw_array[1] != 'never' )) {
  170. return '<verify status=\'expired\' message=\'Fetching a new local key.\' ' . $raw_array[9] . ' />';
  171. }
  172.  
  173.  
  174. if (( $raw_array[13] && strcmp( @md5( 'a666d67aae067313345c74abd7b666b0' . $raw_array[13] ), $raw_array[14] ) != 0 )) {
  175. return '<verify status=\'invalid\' message=\'The download controls were tampered with.\' />';
  176. }
  177. .................................................................
  178. ............................
  179. ........
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement