Guest User

Untitled

a guest
Aug 10th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.59 KB | None | 0 0
  1. PHP Formatting error in Aptana
  2. <?php
  3.  
  4. class callerservice extends Model {
  5.  
  6. var $API_UserName;
  7.  
  8. var $API_Password;
  9.  
  10. var $API_Signature;
  11.  
  12. var $API_Endpoint ;
  13.  
  14. var $version;
  15.  
  16. var $subject;
  17. var $CI;
  18. var $USE_PROXY;
  19. var $PROXY_HOST;
  20. var $PROXY_PORT;
  21.  
  22. function callerservice()
  23. {
  24. // Call the Model constructor
  25. parent::Model();
  26.  
  27. $this->CI =& get_instance();
  28. $this->CI->load->helper(‘url’);
  29. $this->CI->load->helper(‘form’);
  30. $this->CI->load->library(‘session’);
  31.  
  32. $this->CI->load->config(‘paypal_constants’);
  33.  
  34. $this->API_UserName = $this->CI->config->item(‘API_USERNAME’);
  35.  
  36. $this->API_Password = $this->CI->config->item(‘API_PASSWORD’);
  37.  
  38. $this->API_Signature = $this->CI->config->item(‘API_SIGNATURE’);
  39.  
  40. $this->API_Endpoint = $this->CI->config->item(‘API_ENDPOINT’);
  41.  
  42. $this->subject = $this->CI->config->item(‘SUBJECT’);
  43.  
  44. $this->version = $this->CI->config->item(‘VERSION’);
  45.  
  46. $this->USE_PROXY = $this->CI->config->item(‘USE_PROXY’);
  47.  
  48. $this->PROXY_HOST = $this->CI->config->item(‘PROXY_HOST’);
  49.  
  50. $this->PROXY_PORT = $this->CI->config->item(‘PROXY_PORT’);
  51.  
  52. }
  53.  
  54. /**
  55. * hash_call: Function to perform the API call to PayPal using API signature
  56. * @methodName is name of API method.
  57. * @nvpStr is nvp string.
  58. * returns an associtive array containing the response from the server.
  59. */
  60.  
  61. function hash_call($methodName,$nvpStr)
  62. {
  63. //declaring of global variables
  64. //global $API_Endpoint,$version,$API_UserName,$API_Password,$API_Signature,$nvp_Header, $subject;
  65.  
  66. //setting the curl parameters.
  67. $ch = curl_init();
  68. curl_setopt($ch, CURLOPT_URL,$this->API_Endpoint);
  69. curl_setopt($ch, CURLOPT_VERBOSE, 1);
  70.  
  71. //turning off the server and peer verification(TrustManager Concept).
  72. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  73. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
  74.  
  75. curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  76. curl_setopt($ch, CURLOPT_POST, 1);
  77. //if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled.
  78. //Set proxy name to PROXY_HOST and port number to PROXY_PORT in constants.php
  79. if($this->USE_PROXY)
  80. curl_setopt ($ch, CURLOPT_PROXY, $this->PROXY_HOST.”:”.$this->PROXY_PORT);
  81.  
  82. //check if version is included in $nvpStr else include the version.
  83. if(strlen(str_replace(‘VERSION=’, ”, strtoupper($nvpStr))) == strlen($nvpStr)) {
  84. $nvpStr = “&VERSION=” . urlencode($this->version) . $nvpStr;
  85. }
  86.  
  87. $nvpreq=”METHOD=”.urlencode($methodName).$nvpStr;
  88.  
  89. //setting the nvpreq as POST FIELD to curl
  90. curl_setopt($ch,CURLOPT_POSTFIELDS,$nvpreq);
  91.  
  92. //getting response from server
  93. $response = curl_exec($ch);
  94.  
  95. //convrting NVPResponse to an Associative Array
  96. $nvpResArray=$this->deformatNVP($response);
  97. $nvpReqArray=$this->deformatNVP($nvpreq);
  98. $ASESSION['nvpReqArray']=$nvpReqArray;
  99.  
  100. if (curl_errno($ch)) {
  101. // moving to display page to display curl errors
  102. $ASESSION['curl_error_no']=curl_errno($ch) ;
  103. $ASESSION['curl_error_msg']=curl_error($ch);
  104. print_r($ch);exit;
  105. //$this->redirect(‘error’);
  106. } else {
  107. //closing the curl
  108. curl_close($ch);
  109. }
  110. $this->CI->session->set_userdata($ASESSION);
  111.  
  112. return $nvpResArray;
  113. }
  114.  
  115. /** This function will take NVPString and convert it to an Associative Array and it will decode the response.
  116. * It is usefull to search for a particular key and displaying arrays.
  117. * @nvpstr is NVPString.
  118. * @nvpArray is Associative Array.
  119. */
  120.  
  121. function deformatNVP($nvpstr)
  122. {
  123.  
  124. $intial=0;
  125. $nvpArray = array();
  126.  
  127. while(strlen($nvpstr)){
  128. //postion of Key
  129. $keypos= strpos($nvpstr,’=');
  130. //position of value
  131. $valuepos = strpos($nvpstr,’&’) ? strpos($nvpstr,’&’): strlen($nvpstr);
  132.  
  133. /*getting the Key and Value values and storing in a Associative Array*/
  134. $keyval=substr($nvpstr,$intial,$keypos);
  135. $valval=substr($nvpstr,$keypos+1,$valuepos-$keypos-1);
  136. //decoding the respose
  137. $nvpArray[urldecode($keyval)] =urldecode( $valval);
  138. $nvpstr=substr($nvpstr,$valuepos+1,strlen($nvpstr));
  139. }
  140. return $nvpArray;
  141. }
  142.  
  143. }
  144. ?>
  145.  
  146. then create a file paypal_constants.php in config folder
  147.  
  148. <?php
  149.  
  150. class callerservice extends Model {
  151.  
  152. var $API_UserName;
  153.  
  154. var $API_Password;
  155.  
  156. var $API_Signature;
  157.  
  158. var $API_Endpoint ;
  159.  
  160. var $version;
  161.  
  162. var $subject;
  163. var $CI;
  164. var $USE_PROXY;
  165. var $PROXY_HOST;
  166. var $PROXY_PORT;
  167.  
  168. function callerservice()
  169. {
  170. // Call the Model constructor
  171. parent::Model();
  172.  
  173. $this->CI =& get_instance();
  174. $this->CI->load->helper(‘url’);
  175. $this->CI->load->helper(‘form’);
  176. $this->CI->load->library(‘session’);
  177.  
  178. $this->CI->load->config(‘paypal_constants’);
  179.  
  180. $this->API_UserName = $this->CI->config->item(‘API_USERNAME’);
  181.  
  182. $this->API_Password = $this->CI->config->item(‘API_PASSWORD’);
  183.  
  184. $this->API_Signature = $this->CI->config->item(‘API_SIGNATURE’);
  185.  
  186. $this->API_Endpoint = $this->CI->config->item(‘API_ENDPOINT’);
  187.  
  188. $this->subject = $this->CI->config->item(‘SUBJECT’);
  189.  
  190. $this->version = $this->CI->config->item(‘VERSION’);
  191.  
  192. $this->USE_PROXY = $this->CI->config->item(‘USE_PROXY’);
  193.  
  194. $this->PROXY_HOST = $this->CI->config->item(‘PROXY_HOST’);
  195.  
  196. $this->PROXY_PORT = $this->CI->config->item(‘PROXY_PORT’);
  197.  
  198. }
  199.  
  200. /**
  201. * hash_call: Function to perform the API call to PayPal using API signature
  202. * @methodName is name of API method.
  203. * @nvpStr is nvp string.
  204. * returns an associtive array containing the response from the server.
  205. */
  206.  
  207. function hash_call($methodName,$nvpStr)
  208. {
  209. //declaring of global variables
  210. //global $API_Endpoint,$version,$API_UserName,$API_Password,$API_Signature,$nvp_Header, $subject;
  211.  
  212. //setting the curl parameters.
  213. $ch = curl_init();
  214. curl_setopt($ch, CURLOPT_URL,$this->API_Endpoint);
  215. curl_setopt($ch, CURLOPT_VERBOSE, 1);
  216.  
  217. //turning off the server and peer verification(TrustManager Concept).
  218. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  219. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
  220.  
  221. curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  222. curl_setopt($ch, CURLOPT_POST, 1);
  223. //if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled.
  224. //Set proxy name to PROXY_HOST and port number to PROXY_PORT in constants.php
  225. if($this->USE_PROXY)
  226. curl_setopt ($ch, CURLOPT_PROXY, $this->PROXY_HOST.”:”.$this->PROXY_PORT);
  227.  
  228. //check if version is included in $nvpStr else include the version.
  229. if(strlen(str_replace(‘VERSION=’, ”, strtoupper($nvpStr))) == strlen($nvpStr)) {
  230. $nvpStr = “&VERSION=” . urlencode($this->version) . $nvpStr;
  231. }
  232.  
  233. $nvpreq=”METHOD=”.urlencode($methodName).$nvpStr;
  234.  
  235. //setting the nvpreq as POST FIELD to curl
  236. curl_setopt($ch,CURLOPT_POSTFIELDS,$nvpreq);
  237.  
  238. //getting response from server
  239. $response = curl_exec($ch);
  240.  
  241. //convrting NVPResponse to an Associative Array
  242. $nvpResArray=$this->deformatNVP($response);
  243. $nvpReqArray=$this->deformatNVP($nvpreq);
  244. $ASESSION['nvpReqArray']=$nvpReqArray;
  245.  
  246. if (curl_errno($ch)) {
  247. // moving to display page to display curl errors
  248. $ASESSION['curl_error_no']=curl_errno($ch) ;
  249. $ASESSION['curl_error_msg']=curl_error($ch);
  250. print_r($ch);exit;
  251. //$this->redirect(‘error’);
  252. } else {
  253. //closing the curl
  254. curl_close($ch);
  255. }
  256. $this->CI->session->set_userdata($ASESSION);
  257.  
  258. return $nvpResArray;
  259. }
  260.  
  261. /** This function will take NVPString and convert it to an Associative Array and it will decode the response.
  262. * It is usefull to search for a particular key and displaying arrays.
  263. * @nvpstr is NVPString.
  264. * @nvpArray is Associative Array.
  265. */
  266.  
  267. function deformatNVP($nvpstr)
  268. {
  269.  
  270. $intial=0;
  271. $nvpArray = array();
  272.  
  273. while(strlen($nvpstr)){
  274. //postion of Key
  275. $keypos= strpos($nvpstr,’=');
  276. //position of value
  277. $valuepos = strpos($nvpstr,’&’) ? strpos($nvpstr,’&’): strlen($nvpstr);
  278.  
  279. /*getting the Key and Value values and storing in a Associative Array*/
  280. $keyval=substr($nvpstr,$intial,$keypos);
  281. $valval=substr($nvpstr,$keypos+1,$valuepos-$keypos-1);
  282. //decoding the respose
  283. $nvpArray[urldecode($keyval)] =urldecode( $valval);
  284. $nvpstr=substr($nvpstr,$valuepos+1,strlen($nvpstr));
  285. }
  286. return $nvpArray;
  287. }
  288.  
  289. }
  290. ?>
  291.  
  292. -- Error Details --
  293. Date: Thu Dec 08 15:32:24 CET 2011
  294. Message: Error while formatting the code in your editor.Please submit a bug report through Studio's support and include the relevant code which triggered this error.
  295. Severity: Error
  296. Product: Aptana Studio 3 3.0.6.201110251455 (com.aptana.rcp.product)
  297. Plugin: com.aptana.formatter.epl
  298. Session Data:
  299. eclipse.buildId=unknown
  300. java.version=1.6.0_29
  301. java.vendor=Apple Inc.
  302. BootLoader constants: OS=macosx, ARCH=x86, WS=cocoa, NL=en_US
  303. Framework arguments: -keyring /Users/alex/.eclipse_keyring -showlocation
  304. Command-line arguments: -os macosx -ws cocoa -arch x86 -keyring /Users/alex/.eclipse_keyring -consoleLog -showlocation
  305.  
  306.  
  307. Error
  308. Thu Dec 08 15:32:24 CET 2011
  309. Error while formatting the code in your editor.Please submit a bug report through Studio's support and include the relevant code which triggered this error.
Add Comment
Please, Sign In to add comment