BlueWall

landtool.php

Feb 3rd, 2012
1,228
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. #
  3. # Copyright (c)Melanie Thielker and Teravus Ovares (http://opensimulator.org/)
  4. #
  5. # Redistribution and use in source and binary forms, with or without
  6. # modification, are permitted provided that the following conditions are met:
  7. # * Redistributions of source code must retain the above copyright
  8. # notice, this list of conditions and the following disclaimer.
  9. # * Redistributions in binary form must reproduce the above copyright
  10. # notice, this list of conditions and the following disclaimer in the
  11. # documentation and/or other materials provided with the distribution.
  12. # * Neither the name of the OpenSim Project nor the
  13. # names of its contributors may be used to endorse or promote products
  14. # derived from this software without specific prior written permission.
  15. #
  16. # THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. # DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. #
  27.  
  28. # updated for Robust installations: BlueWall 2011
  29.  
  30.  
  31. #
  32. # Settings
  33. #
  34. $dbhost = "hostname";
  35. $dbname = "database_name";
  36. $dbuser = "database_user";
  37. $dbpass = "database_pass";
  38. #
  39. # Set this to your economy source / sink accounts
  40. $economy_source_account = "3d6181b0-6a4b-97ef-18d8-722652995cf1";
  41. $economy_sink_account="3d6181b0-6a4b-97ef-18d8-722652995cf1";
  42.  
  43. # Tables
  44. $presence = "Presence";
  45.  
  46. $xmlrpc_server = xmlrpc_server_create();
  47.  
  48. function process_transaction($avatarId, $amount, $ipAddress)
  49. {
  50. # Do Credit Card Processing here! Return False if it fails!
  51. # Remember, $amount is stored without decimal places, however it's assumed
  52. # that the transaction amount is in Cents and has two decimal places
  53. # 5 dollars will be 500
  54. # 15 dollars will be 1500
  55.  
  56. return True;
  57. }
  58.  
  59. function validate_user($agent_id, $s_session_id)
  60. {
  61. global $dbhost, $dbuser, $dbpass, $dbname;
  62.  
  63. $agentid = mysql_escape_string($agent_id);
  64. $sessionid = mysql_escape_string($s_session_id);
  65.  
  66. $link = mysql_connect($dbhost, $dbuser, $dbpass)
  67. or die('ERROR: '.mysql_error());
  68.  
  69. mysql_select_db($dbname);
  70.  
  71. $query = "select UserID from Presence where UserID='".$agentid."' and SecureSessionID = '".$sessionid."'";
  72.  
  73. $result = mysql_query($query)
  74. or die('ERROR: '.mysql_error());
  75.  
  76. $row = mysql_fetch_assoc($result);
  77.  
  78. return $row['UserID'];
  79. }
  80.  
  81.  
  82. xmlrpc_server_register_method($xmlrpc_server, "preflightBuyLandPrep",
  83. "buy_land_prep");
  84.  
  85. function buy_land_prep($method_name, $params, $app_data)
  86. {
  87. global $dbhost, $dbuser, $dbpass, $dbname;
  88.  
  89. $confirmvalue = "";
  90. $req = $params[0];
  91. $agentid = $req['agentId'];
  92. $sessionid = $req['secureSessionId'];
  93. $amount = $req['currencyBuy'];
  94. $billableArea = $req['billableArea'];
  95.  
  96. $ID = validate_user($agentid, $sessionid);
  97.  
  98. if($ID)
  99. {
  100. $membership_levels = array(
  101. 'levels' => array(
  102. 'id' => "00000000-0000-0000-0000-000000000000",
  103. 'description' => "some level"));
  104.  
  105. $landUse = array(
  106. 'upgrade' => False,
  107. 'action' => "".SYSURL."");
  108.  
  109. $currency = array(
  110. 'estimatedCost' => "200.00"); // convert_to_real($amount));
  111.  
  112. $membership = array(
  113. 'upgrade' => False,
  114. 'action' => "".SYSURL."",
  115. 'levels' => $membership_levels);
  116.  
  117. $response_xml = xmlrpc_encode(array(
  118. 'success' => True,
  119. 'currency' => $currency,
  120. 'membership' => $membership,
  121. 'landUse' => $landUse,
  122. 'currency' => $currency,
  123. 'confirm' => $confirmvalue));
  124.  
  125. header("Content-type: text/xml");
  126. print $response_xml;
  127. }
  128. else
  129. {
  130. header("Content-type: text/xml");
  131. $response_xml = xmlrpc_encode(array(
  132. 'success' => False,
  133. 'errorMessage' => "\n\nUnable to Authenticate\n\nClick URL for more info.",
  134. 'errorURI' => "".SYSURL.""));
  135.  
  136. print $response_xml;
  137. }
  138.  
  139. return "";
  140. }
  141.  
  142. $request_xml = $HTTP_RAW_POST_DATA;
  143. xmlrpc_server_call_method($xmlrpc_server, $request_xml, '');
  144. xmlrpc_server_destroy($xmlrpc_server);
  145.  
  146. ?>
RAW Paste Data