风岭社区

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 3759|回复: 2

转贴:最新开心版WHMCS下载(含LIC文件)

[复制链接]
发表于 2017-2-6 08:30:14 | 显示全部楼层 |阅读模式
WHMCS版本为6.2.2,从官方下载,未解密,未添加任何代码
链接:http://pan.baidu.com/s/1c0K5u8o 密码:lryj

lic文件:
  1. <?php
  2. namespace WHMCS;
  3. class License {
  4.     protected $licensekey = '';
  5.     protected $localkey = '';
  6.     protected $keydata = array(  );
  7.     protected $salt = '';
  8.     protected $date = '';
  9.     protected $localkeydecoded = '';
  10.     protected $responsedata = '';
  11.     protected $postmd5hash = '';
  12.     protected $localkeydays = '10';
  13.     protected $allowcheckfaildays = '5';
  14.     protected $debuglog = array(  );
  15.     protected $version = '7a1bbff560de83ab800c4d1d2f215b91006be8e6';

  16. function __construct() {
  17.     $whmcs = Application::getinstance(  );
  18.     $this->licensekey = $whmcs->get_license_key(  );
  19.     $this->localkey = $whmcs->get_config( 'License' );
  20.     $this->salt = sha1( 'WHMCS' . $whmcs->get_config( 'Version' ) . 'TFB' . $whmcs->get_hash(  ) );
  21.     $this->date = date( 'Ymd' );
  22.     $this->decodeLocalOnce(  );

  23.     if (isset( $_GET['forceremote'] )) {
  24.         $this->forceRemoteCheck(  );
  25.         Terminus::getinstance(  )->doExit(  );
  26.     }

  27. }

  28. function setInstance($license) {
  29.     $license = self::$instance;
  30.     return $license;
  31. }

  32. function destroyInstance() {
  33.     self::$instance = null;
  34. }

  35. function getInstance() {
  36.     if (is_null(self::$instance))
  37.     {
  38.         self::setinstance(new License());
  39.     }

  40.     return self::$instance;
  41. }

  42. function getHosts() {
  43.     $hosts = gethostbynamel( 'licensing28.whmcs.com' );

  44.     if ($hosts === false) {
  45.         $hosts = array(  );
  46.     }

  47.     return $hosts;
  48. }

  49. function getLicenseKey() {
  50.     return $this->licensekey;
  51. }

  52. function getHostIP() {
  53.     if (isset( $_SERVER['SERVER_ADDR'] )) {
  54.         $ip = $_SERVER['SERVER_ADDR'];
  55.     } else {
  56.         if (isset( $_SERVER['LOCAL_ADDR'] )) {
  57.             $ip = $_SERVER['LOCAL_ADDR'];
  58.         } else {
  59.             if (function_exists( 'gethostname' )) {
  60.                 $ip = gethostbyname( gethostname(  ) );
  61.             } else {
  62.                 $ip = '';
  63.             }
  64.         }
  65.     }

  66.     return $ip;
  67. }

  68. function getHostDomain() {
  69.     return (isset( $_SERVER['SERVER_NAME'] ) ? $_SERVER['SERVER_NAME'] : '');
  70. }

  71. function getHostDir() {
  72.     return ROOTDIR;
  73. }

  74. function getSalt() {
  75.     return $this->salt;
  76. }

  77. function getDate() {
  78.     return $this->date;
  79. }

  80. function checkLocalKeyExpiry() {
  81.     $originalcheckdate = $this->getKeyData( 'checkdate' );
  82.     $localexpirymax = date( 'Ymd', mktime( 0, 0, 0, date( 'm' ), date( 'd' ) - $this->localkeydays, date( 'Y' ) ) );

  83.     if ($originalcheckdate < $localexpirymax) {
  84.         return false;
  85.     }

  86.     $localmax = date( 'Ymd', mktime( 0, 0, 0, date( 'm' ), date( 'd' ) + 2, date( 'Y' ) ) );

  87.     if ($localmax < $originalcheckdate) {
  88.         return false;
  89.     }

  90.     return true;
  91. }

  92. function remoteCheck($forceRemote = false) {
  93.     try {
  94.         $localkeyvalid = $this->decodeLocalOnce(  );
  95.         $this->debug( '' . 'Local Key Valid: ' . $localkeyvalid );

  96.         if ($localkeyvalid) {
  97.             $localkeyvalid = $this->checkLocalKeyExpiry(  );
  98.             $this->debug( '' . 'Local Key Expiry: ' . $localkeyvalid );

  99.             if ($localkeyvalid) {
  100.                 $localkeyvalid = $this->validateLocalKey(  );
  101.                 $this->debug( '' . 'Local Key Validation: ' . $localkeyvalid );
  102.             }
  103.         }


  104.         if ( !$localkeyvalid || $forceRemote ) {
  105.             $whmcs                     = Application::getinstance();
  106.             $results["status"]         = "Active";
  107.             $results["key"]            = $this->licensekey;
  108.             $results["registeredname"] = $whmcs->get_config("CompanyName");
  109.             $results["productname"]    = "Owned License No Branding";
  110.             $results["productid"]      = "5";
  111.             $results["billingcycle"]   = "One Time";
  112.             $results["validdomains"]   = $this->getHostDomain();
  113.             $results["validips"]       = $this->getHostIP();
  114.             $results["validdirs"]      = $this->getHostDir();
  115.             $results["checkdate"]      = $this->getDate();
  116.             $results["version"]        = $whmcs->getVersion()->getCanonical();
  117.             $results["regdate"]        = "2014-02-06";
  118.             $results["nextduedate"]    = "2050-02-06";
  119.             $results["addons"]         = array(
  120.                 array(
  121.                     'name' => 'Branding Removal',
  122.                     'nextduedate' => '2050-12-30',
  123.                     'status' => 'Active'
  124.                 ),
  125.                 array(
  126.                     'name' => 'Support and Updates',
  127.                     'nextduedate' => '2050-12-30',
  128.                     'status' => 'Active'
  129.                 ),
  130.                 array(
  131.                     'name' => 'Project Management Addon',
  132.                     'nextduedate' => '2050-12-30',
  133.                     'status' => 'Active'
  134.                 ),
  135.                 array(
  136.                     'name' => 'Licensing Addon',
  137.                     'nextduedate' => '2050-12-30',
  138.                     'status' => 'Active'
  139.                 ),
  140.                 array(
  141.                     'name' => 'Mobile Edition',
  142.                     'nextduedate' => '2050-12-30',
  143.                     'status' => 'Active'
  144.                 ),
  145.                 array(
  146.                     'name' => 'iPhone App',
  147.                     'nextduedate' => '2050-12-30',
  148.                     'status' => 'Active'
  149.                 ),
  150.                 array(
  151.                     'name' => 'Android App',
  152.                     'nextduedate' => '2050-12-30',
  153.                     'status' => 'Active'
  154.                 ),
  155.                 array(
  156.                     'name' => 'Configurable Package Addon',
  157.                     'nextduedate' => '2050-12-30',
  158.                     'status' => 'Active'
  159.                 ),
  160.                 array(
  161.                     'name' => 'Live Chat Monthly No Branding',
  162.                     'nextduedate' => '2050-12-30',
  163.                     'status' => 'Active'
  164.                 )
  165.             );
  166.             $this->setKeyData($results);
  167.             $this->updateLocalKey();
  168.         }

  169.         $this->debug( 'Remote Check Done' );
  170.     }
  171.     catch (Exception $exception) {
  172.         $this->debug( sprintf( 'License Error: %s', $exception->getMessage(  ) ) );
  173.         return false;
  174.     }
  175.     return true;
  176. }

  177. function getLocalMaxExpiryDate() {
  178.     return date( 'Ymd', mktime( 0, 0, 0, date( 'm' ), date( 'd' ) - ( $this->localkeydays + $this->allowcheckfaildays ), date( 'Y' ) ) );
  179. }

  180. function buildQuery($postfields) {
  181.     $query_string = '';
  182.     foreach ($postfields as $k => $v) {
  183.         $query_string .= $k . '=' . urlencode( $v ) . '&';
  184.     }

  185.     return $query_string;
  186. }

  187. function callHome($postfields) {
  188.     $query_string = $this->buildQuery( $postfields );
  189.     $res = $this->callHomeLoop( $query_string, 5 );

  190.     if ($res) {
  191.         return $res;
  192.     }

  193.     return $this->callHomeLoop( $query_string, 30 );
  194. }

  195. function callHomeLoop($query_string, $timeout = 5) {
  196.     $hostips = $this->getHosts(  );
  197.     foreach ($hostips as $hostip) {
  198.         $responsecode = $this->makeCall( $hostip, $query_string, $timeout );

  199.         if ($responsecode == 200) {
  200.             return $this->responsedata;
  201.         }
  202.     }

  203.     return false;
  204. }

  205. function makeCall($ip, $query_string, $timeout = 5) {
  206.     $url = 'https://' . $ip . '/license/verify53.php';
  207.     $this->debug( '' . 'Request URL ' . $url );
  208.     $ch = curl_init(  );
  209.     curl_setopt( $ch, CURLOPT_URL, $url );
  210.     curl_setopt( $ch, CURLOPT_POST, 1 );
  211.     curl_setopt( $ch, CURLOPT_POSTFIELDS, $query_string );
  212.     curl_setopt( $ch, CURLOPT_TIMEOUT, $timeout );
  213.     curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
  214.     curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0 );
  215.     curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 );
  216.     $this->responsedata = curl_exec( $ch );
  217.     $responsecode = curl_getinfo( $ch, CURLINFO_HTTP_CODE );
  218.     $this->debug( '' . 'Response Code: ' . $responsecode . ' Data: ' . $this->responsedata );

  219.     if (curl_error( $ch )) {
  220.         $this->debug( 'Curl Error: ' . curl_error( $ch ) . ' - ' . curl_errno( $ch ) );
  221.     }

  222.     curl_close( $ch );
  223.     return $responsecode;
  224. }

  225. function processResponse($data) {
  226.     $data = strrev( $data );
  227.     $data = base64_decode( $data );
  228.     $results = unserialize( $data );
  229.     $this->posthash = $results['hash'];
  230.     unset( $results['hash'] );
  231.     $results['checkdate'] = $this->getDate(  );
  232.     return $results;
  233. }

  234. function updateLocalKey()
  235. {
  236.     $data_encoded = serialize($this->keydata);
  237.     $data_encoded = base64_encode($data_encoded);
  238.     $data_encoded = sha1($this->getDate() . $this->getSalt()) . $data_encoded;
  239.     $data_encoded = strrev($data_encoded);
  240.     $splpt = strlen($data_encoded) / 2;
  241.     $data_encoded = substr($data_encoded, $splpt) . substr($data_encoded, 0, $splpt);
  242.     $data_encoded = sha1($data_encoded . $this->getSalt()) . $data_encoded . sha1($data_encoded . $this->getSalt() . time());
  243.     $data_encoded = base64_encode($data_encoded);
  244.     $data_encoded = wordwrap($data_encoded, 80, "\n", true);
  245.     Application::getinstance()->set_config("License", $data_encoded);
  246.     $this->debug("Updated Local Key");
  247.     return null;
  248. }

  249. function forceRemoteCheck() {
  250.     $this->remoteCheck( true );
  251. }

  252. function setInvalid($reason = 'Invalid') {
  253.     $this->keydata = array( 'status' => $reason );
  254. }

  255. function decodeLocal()
  256. {
  257.     $this->debug("Decoding local key");
  258.     $localkey = $this->localkey;

  259.     if (!$localkey)
  260.     {
  261.         return false;
  262.     }

  263.     $localkey = str_replace("\n", "", $localkey);
  264.     $localkey = base64_decode($localkey);
  265.     $localdata = substr($localkey, 40, 0 - 40);
  266.     $md5hash = substr($localkey, 0, 40);

  267.     if ($md5hash == sha1($localdata . $this->getSalt()))
  268.     {
  269.         $splpt = strlen($localdata) / 2;
  270.         $localdata = substr($localdata, $splpt) . substr($localdata, 0, $splpt);
  271.         $localdata = strrev($localdata);
  272.         $md5hash = substr($localdata, 0, 40);
  273.         $localdata = substr($localdata, 40);
  274.         $localdata = base64_decode($localdata);
  275.         $localkeyresults = unserialize($localdata);
  276.         $originalcheckdate = $localkeyresults['checkdate'];

  277.         if ($md5hash == sha1($originalcheckdate . $this->getSalt()))
  278.         {
  279.             if (isset($localkeyresults['key']) && $localkeyresults['key'] == Application::getinstance()->get_license_key())
  280.             {
  281.                 $this->debug("Local Key Decode Successful");
  282.                 $this->setKeyData($localkeyresults);
  283.             }
  284.             else
  285.             {
  286.                 $this->debug("License Key Invalid");
  287.             }
  288.         }
  289.         else
  290.         {
  291.             $this->debug("Local Key MD5 Hash 2 Invalid");
  292.         }
  293.     }
  294.     else
  295.     {
  296.         $this->debug("Local Key MD5 Hash Invalid");
  297.     }

  298.     $this->localkeydecoded = true;
  299.     return $this->getKeyData("status") == "Active" ? true : false;
  300. }

  301. function decodeLocalOnce() {
  302.     if ($this->localkeydecoded) {
  303.         return true;
  304.     }

  305.     return $this->decodeLocal(  );
  306. }

  307. function isRunningInCLI() {
  308.     return ( php_sapi_name(  ) == 'cli' && empty( $_SERVER['REMOTE_ADDR'] ) );
  309. }

  310. function validateLocalKey() {
  311.     if ($this->getKeyData( 'status' ) != 'Active') {
  312.         $this->debug( 'Local Key Status Check Failure' );
  313.         return false;
  314.     }


  315.     if ($this->isRunningInCLI(  )) {
  316.         $this->debug( 'Running in CLI Mode' );
  317.     } else {
  318.         $this->debug( 'Running in Browser Mode' );

  319.         if ($this->isValidDomain( $this->getHostDomain(  ) )) {
  320.             $this->debug( 'Domain Validated Successfully' );
  321.         } else {
  322.             $this->debug( 'Local Key Domain Check Failure' );
  323.             return false;
  324.         }

  325.         $ip = $this->getHostIP(  );
  326.         $this->debug( '' . 'Host IP Address: ' . $ip );

  327.         if (!$ip) {
  328.             $this->debug( 'IP Could Not Be Determined - Skipping Local Validation of IP' );
  329.         } else {
  330.             if (!trim( $this->getKeyData( 'validips' ) )) {
  331.                 $this->debug( 'No Valid IPs returned by license check - Cloud Based License - Skipping Local Validation of IP' );
  332.             } else {
  333.                 if ($this->isValidIP( $ip )) {
  334.                     $this->debug( 'IP Validated Successfully' );
  335.                 } else {
  336.                     $this->debug( 'Local Key IP Check Failure' );
  337.                     return false;
  338.                 }
  339.             }
  340.         }
  341.     }


  342.     if ($this->isValidDir( $this->getHostDir(  ) )) {
  343.         $this->debug( 'Directory Validated Successfully' );
  344.     }
  345.     else {
  346.         $this->debug( 'Local Key Directory Check Failure' );
  347.         return false;
  348.     }

  349.     return true;
  350. }

  351. function isValidDomain($domain) {
  352.     $validdomains = $this->getArrayKeyData( 'validdomains' );
  353.     return in_array( $domain, $validdomains );
  354. }

  355. function isValidIP($ip) {
  356.     $validips = $this->getArrayKeyData( 'validips' );
  357.     return in_array( $ip, $validips );
  358. }

  359. function isValidDir($dir) {
  360.     $validdirs = $this->getArrayKeyData( 'validdirs' );
  361.     return in_array( $dir, $validdirs );
  362. }

  363. function revokeLocal() {
  364.     Application::getinstance(  )->set_config( 'License', '' );
  365. }

  366. function getKeyData($var) {
  367.     return (isset( $this->keydata[$var] ) ? $this->keydata[$var] : '');
  368. }

  369. function setKeyData($data) {
  370.     $this->keydata = $data;
  371. }

  372. function getArrayKeyData($var) {
  373.     $listData = array(  );
  374.     $rawData = $this->getKeyData( $var );

  375.     if (is_string( $rawData )) {
  376.         $listData = explode( ',', $rawData );
  377.         foreach ($listData as $k => $v) {
  378.             if (is_string( $v )) {
  379.                 $listData[$k] = trim( $v );
  380.                 continue;
  381.             }

  382.             throw new Exception( 'Invalid license data structure' );
  383.         }
  384.     } else {
  385.         if (!is_null( $rawData )) {
  386.             throw new Exception( 'Invalid license data structure' );
  387.         }
  388.     }

  389.     return $listData;
  390. }

  391. function getRegisteredName() {
  392.     return $this->getKeyData( 'registeredname' );
  393. }

  394. function getProductName() {
  395.     return $this->getKeyData( 'productname' );
  396. }

  397. function getStatus() {
  398.     return $this->getKeyData( 'status' );
  399. }

  400. function getSupportAccess() {
  401.     return $this->getKeyData( 'supportaccess' );
  402. }

  403. function getLicensedAddons() {
  404.     $licensedAddons = $this->getKeyData( 'addons' );

  405.     if (!is_array( $licensedAddons )) {
  406.         $licensedAddons = array(  );
  407.     }

  408.     return $licensedAddons;
  409. }

  410. function getActiveAddons() {
  411.     $licensedAddons = $this->getLicensedAddons(  );
  412.     $activeAddons = array(  );
  413.     foreach ($licensedAddons as $addon) {
  414.         if ($addon['status'] == 'Active') {
  415.             $activeAddons[] = $addon['name'];
  416.             continue;
  417.         }
  418.     }

  419.     return $activeAddons;
  420. }

  421. function isActiveAddon($addon) {
  422.     return (in_array( $addon, $this->getActiveAddons(  ) ) ? true : false);
  423. }

  424. function getExpiryDate($showday = false) {
  425.     $expiry = $this->getKeyData( 'nextduedate' );

  426.     if (!$expiry) {
  427.         $expiry = 'Never';
  428.     } else {
  429.         if ($showday) {
  430.             $expiry = date( 'l, jS F Y', strtotime( $expiry ) );
  431.         } else {
  432.             $expiry = date( 'jS F Y', strtotime( $expiry ) );
  433.         }
  434.     }

  435.     return $expiry;
  436. }

  437. function getLatestPublicVersion() {
  438.     try {
  439.         $latestVersion = new Version\SemanticVersion ($this->getKeyData( 'latestpublicversion' ));
  440.     }
  441.     catch (Exception\Version\BadVersionNumber $e) {
  442.         $whmcs = Application::getinstance(  );
  443.         $latestVersion = $whmcs->getVersion(  );
  444.     }
  445.     return $latestVersion;
  446. }

  447. function getLatestPreReleaseVersion() {
  448.     try {
  449.         $latestVersion = new Version\SemanticVersion($this->getKeyData( 'latestprereleaseversion' ));
  450.     }
  451.     catch (Exception\Version\BadVersionNumber $e) {
  452.         $whmcs = Application::getinstance(  );
  453.         $latestVersion = $whmcs->getVersion(  );
  454.     }
  455.     return $latestVersion;
  456. }

  457. function getLatestVersion() {
  458.     $whmcs = Application::getinstance(  );
  459.     $installedVersion = $whmcs->getVersion(  );

  460.     if (in_array( $installedVersion->getPreReleaseIdentifier(  ), array( 'beta', 'rc' ) )) {
  461.         $latestVersion = $this->getLatestPreReleaseVersion(  );
  462.     } else {
  463.         $latestVersion = $this->getLatestPublicVersion(  );
  464.     }

  465.     return $latestVersion;
  466. }

  467. function isUpdateAvailable() {
  468.     $whmcs = Application::getinstance(  );
  469.     $installedVersion = $whmcs->getVersion(  );
  470.     $latestVersion = $this->getLatestVersion(  );
  471.     return Version\SemanticVersion::compare( $latestVersion, $installedVersion, '>' );
  472. }

  473. function getRequiresUpdates() {
  474.     return ($this->getKeyData( 'requiresupdates' ) ? true : false);
  475. }

  476. function checkOwnedUpdates() {
  477.     if (!$this->getRequiresUpdates(  )) {
  478.         return true;
  479.     }

  480.     $whmcs = Application::getinstance(  );
  481.     $licensedAddons =  $this->getLicensedAddons(  );
  482.     foreach ($licensedAddons as $addon) {
  483.         if ( $addon['name'] == 'Support and Updates' && $addon['status'] == 'Active' ) {
  484.             if (str_replace( '-', '', $whmcs->getReleaseDate(  ) ) <= str_replace( '-', '', $addon['nextduedate'] )) {
  485.                 return true;
  486.                 continue;
  487.             }

  488.             continue;
  489.         }
  490.     }

  491.     return false;
  492. }

  493. function getBrandingRemoval() {
  494.     if (in_array( $this->getProductName(  ), array( 'Owned License No Branding', 'Monthly Lease No Branding' ) )) {
  495.         return true;
  496.     }

  497.     $licensedAddons = $this->getLicensedAddons(  );
  498.     foreach ($licensedAddons as $addon) {
  499.         if ( $addon['name'] == 'Branding Removal' && $addon['status'] == 'Active' ) {
  500.             return true;
  501.             continue;
  502.         }
  503.     }

  504.     return false;
  505. }

  506. function getVersionHash() {
  507.     return $this->version;
  508. }

  509. function debug($msg) {
  510.     $this->debuglog[] = $msg;
  511. }

  512. function getDebugLog() {
  513.     return $this->debuglog;
  514. }

  515. function isClientLimitsEnabled() {
  516.     return (string)$this->getKeyData( 'ClientLimitsEnabled' );
  517. }

  518. function getClientLimit() {
  519.     $clientLimit = $this->getKeyData( 'ClientLimit' );

  520.     if ($clientLimit == '') {
  521.         return 0 - 1;
  522.     }


  523.     if (!is_numeric( $clientLimit )) {
  524.         $this->debug( 'Invalid client limit value in license' );
  525.         return 0;
  526.     }

  527.     return (int)$clientLimit;
  528. }

  529. function getTextClientLimit($admin = null) {
  530.     $clientLimit = $this->getClientLimit(  );
  531.     $result = 'Unlimited';

  532.     if (0 < $clientLimit) {
  533.         $result = number_format( $clientLimit, 0, '', ',' );
  534.     } else {
  535.         if ($admin && $text = $admin->lang( 'global', 'unlimited' )) {
  536.             $result = $text;
  537.         }
  538.     }

  539.     return $result;
  540. }

  541. function getNumberOfActiveClients() {
  542.     return (int)get_query_val( 'tblclients', 'count(id)', 'status=\'Active\'' );
  543. }

  544. function getTextNumberOfActiveClients($admin = null) {
  545.     $clientLimit = $this->getNumberOfActiveClients(  );
  546.     $result = 'None';

  547.     if (0 < $clientLimit) {
  548.         $result = number_format( $clientLimit, 0, '', ',' );
  549.     } else {
  550.         if ($admin && $text = $admin->lang( 'global', 'none' )) {
  551.             $result = $text;
  552.         }
  553.     }

  554.     return $result;
  555. }

  556. function getClientBoundaryId() {
  557.     return (int)get_query_val( 'tblclients', 'id', 'status=\'Active\'', 'id', 'ASC', (int)$this->getClientLimit(  ) . ',1' );
  558. }

  559. function isNearClientLimit() {
  560.     $clientLimit = $this->getClientLimit(  );
  561.     $numClients = $this->getNumberOfActiveClients(  );

  562.     if ($numClients < 1 || $clientLimit < 1) {
  563.         return false;
  564.     }

  565.     $percentageBound = (250 < $clientLimit ? 0.0500000000000000027755576 : 0.100000000000000005551115);
  566.     return $clientLimit * ( 1 - $percentageBound ) <= $numClients;
  567. }

  568. function getMemberPublicKey() {
  569.     return '-----BEGIN PUBLIC KEY-----
  570.         MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA7OMhxWvu3FOqMblJGXjh
  571.         vZQLhQa2wRQoetxAM7j/c+SzFVHmLteAZrn06FeoU1RhjQz9TE0kD6BzoBBuE1bm
  572.         JkybOuhVJGVlI8QqLnl2F/jDFP3xshm2brRUt9vNBWXhGDRvOLOgmxaFtVjCiNAT
  573.         9n4dtG+344xN7w568Rw3hnnGApypGFtypaKHSeNV6waeFgHeePXSPFMUpe9evZJa
  574.         pyc9ENEWvi6nK9hWm1uZ+CfoeRjIKqW2QlgazGDqQtQev05LbDihK0Nc8LBqmVQS
  575.         NB/N2CueyYKrzVUmNqbrkJaBVm6N3EnSNBOR7WXOPf1VOjGDu79kYrbhT1MUlKpp
  576.         LQIDAQAB
  577.         -----END PUBLIC KEY-----';
  578. }

  579. function encryptMemberData($data = array(  ), &$publicKey = '') {
  580.     if (!$publicKey) {
  581.         $publicKey = $this->getMemberPublicKey(  );
  582.     }

  583.     $publicKey = str_replace( array( "\n", "\r", " " ), array( '', '', '' ), $publicKey );
  584.     $cipherText = '';

  585.     if (is_array( $data )) {
  586.         try {
  587.             $rsa = new Crypt_RSA(  );
  588.             $rsa->loadKey( $publicKey );
  589.             $rsa->setEncryptionMode( CRYPT_RSA_ENCRYPTION_OAEP );
  590.             $cipherText = $rsa->encrypt( json_encode( $data ) );

  591.             if (!$cipherText) {
  592.                 throw new Exception( 'Could not perform rsa encryption' );
  593.             } else {
  594.                 $cipherText = base64_encode( $cipherText );
  595.             }
  596.         }
  597.         catch (Exception $e) {
  598.             $this->debug( 'Failed to encrypt member data' );
  599.         }
  600.     }

  601.     return $cipherText;
  602. }
  603. }?>
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|Comsenz Inc.

GMT+8, 2024-4-27 09:08 , Processed in 0.035609 second(s), 5 queries , File On.

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表