Advertisement
pushtook

ajax

Nov 19th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.88 KB | None | 0 0
  1.  
  2. function pu_login(){
  3.  
  4. $username = $_REQUEST['username'];
  5. $password = $_REQUEST['password'];
  6. $customer_id = $_REQUEST['customer_id'];
  7.  
  8.     $curl = curl_init();
  9.  
  10.     curl_setopt_array($curl, array(
  11.         CURLOPT_URL => "http://212.235.34.9/tzviCohenSite/WebService.asmx/erpSite_getIsUserExist",
  12.         CURLOPT_RETURNTRANSFER => true,
  13.         CURLOPT_ENCODING => "",
  14.         CURLOPT_MAXREDIRS => 10,
  15.         CURLOPT_TIMEOUT => 30,
  16.         CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  17.         CURLOPT_CUSTOMREQUEST => "POST",
  18.         CURLOPT_POSTFIELDS => "UserName=$username&Password=$password&CustomerId=$customer_id&cmpId=1",
  19.         CURLOPT_HTTPHEADER => array(
  20.             "cache-control: no-cache",
  21.             "content-type: application/x-www-form-urlencoded;charset=\"utf-8\""
  22.         ),
  23.     ));
  24.  
  25.     $response = curl_exec($curl);
  26.     $err = curl_error($curl);
  27.  
  28.     curl_close($curl);
  29.  
  30.     $xml = simplexml_load_string($response);
  31. /*
  32. $to = 'eyal@pushtook.co.il';
  33.  
  34.  
  35.  
  36. $subject = 'צבי כהן';
  37.  
  38.  
  39.  
  40. $body = '<html>';
  41.  
  42. $body.= '<body dir="ltr">';
  43.  
  44. $body.= '<div>';
  45.  
  46. $body.= 'response: '. $response;
  47.  
  48. $body.= '</div>';
  49.  
  50. $body.= '<div>';
  51.  
  52. $body.= 'xml: '.$xml;
  53.  
  54. $body.= '</div>';
  55.  
  56. $body.= '</body>';
  57.  
  58. $body.= '</html>';
  59.  
  60.  
  61.  
  62. $headers = array('Content-Type: text/html; charset=UTF-8');
  63.  
  64.  
  65.  
  66. wp_mail( $to, '=?utf-8?B?'.base64_encode($subject).'?=', $body, $headers );
  67. */
  68.     if ($err) {
  69.         echo json_encode("false");
  70.         die();
  71.     } else {
  72.         if((string)$xml == "1") {
  73.             echo json_encode("true");
  74.             die();
  75.         }elseif ((string)$xml == "9") {
  76.             echo json_encode("blocked");
  77.             die();
  78.         }
  79.         else {
  80.             echo json_encode("false2");
  81.             die();
  82.         }
  83.     }
  84. }
  85. add_action( 'wp_ajax_pu_login', 'pu_login' );
  86. add_action( 'wp_ajax_nopriv_pu_login', 'pu_login' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement