SHARE
TWEET

Untitled

a guest Jun 8th, 2017 102 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if (isset($APP->request->post->generate_awb)) {
  2.     echo $APP->request->post->cont_colector;
  3.  
  4.     $username= 'clienttest';
  5.     $client_id='7032158';
  6.     $user_pass ='testing';
  7.  
  8.  
  9.     $service = $APP->request->post->serviciu;
  10.     $envelopes = $APP->request->post->plic;
  11.     $parcels = $APP->request->post->colete;
  12.     $weight = $APP->request->post->greutate;
  13.     $payment = $APP->request->post->plata;
  14.     $reimbursement = $APP->request->post->ramburs;
  15.     $reimbursement_payment = $APP->request->post->ramburs_colet;
  16.     $declared_value= $APP->request->post->val_colet;
  17.     $contactperson = $APP->request->post->pers_contact;
  18.     $observations = $APP->request->post->obs;
  19.     $content = $APP->request->post->content;
  20.     $recipient = 'test';
  21.     $contact_person = $APP->request->post->pers_contact;;
  22.     $phone=$APP->request->post->telefon;
  23.     $fax ='';
  24.     $email='';
  25.     $county = $APP->request->post->judet;
  26.     $town = $APP->request->post->localitate;
  27.     $street = $APP->request->post->adresa;
  28.     $street_no = '';
  29.     $zip_code = '';
  30.     $block='';
  31.     $entrance='';
  32.     $floor='';
  33.     $flat='';
  34.     $height='';
  35.     $width='';
  36.     $length='';
  37.     $refund='';
  38.     $cost_center='';
  39.     $options='A';
  40.     $packing='';
  41.     $personal_data='';
  42.  
  43.     $csv= "Type of service|Bank|IBAN|Nr. of envelopes|Nr. of parcels|Weight|Payment of shipment|Reimbursement(money)|Reimbursement transport payment|Declared Value|Contact person|Observations|Contains|Recipient name|Contact person|Phone|Fax|Email|County|Town|Street|Number|Postal Code|Block(building)|Entrance|Floor|Flat|Height of packet|Width of packet|Length of packet|Refund|Cost Center|Options|Packing|Personal data
  44.     {$service}|||{$envelopes}|{$parcels}|{$weight}|{$payment}|{$reimbursement}|{$reimbursement_payment}|{$declared_value}|{$contactperson}|{$observations}|{$content}|{$recipient}|{$contact_person}|{$phone}|{$fax}|{$email}|{$county}|{$town}|{$street}|{$street_no}|{$zip_code}|{$block}|{$entrance}|{$floor}|{$flat}|{$height}|{$width}|{$length}|{$refund}|{$cost_center}|{$options}|{$packing}|{$personal_data}";
  45.  
  46.     $destination = "https://www.selfawb.ro/import_awb_integrat.php";
  47.     $data = '';
  48.     $mime_boundary=md5(time());
  49.     $data .= '--' . $mime_boundary . "\n";
  50.     $data .= 'Content-Disposition: form-data; name="username"' . "\n" . "\n";
  51.     $data .= $username . "\n";
  52.     $data .= '--' . $mime_boundary . "\n";
  53.     $data .= 'Content-Disposition: form-data; name="client_id"' . "\n" . "\n";
  54.     $data .= $client_id . "\n";
  55.     $data .= '--' . $mime_boundary . "\n";
  56.     $data .= 'Content-Disposition: form-data; name="user_pass"' . "\n" . "\n";
  57.     $data .= $user_pass . "\n";
  58.     $data .= '--' . $mime_boundary . "\n";
  59.     $data .= 'Content-Disposition: form-data; name="fisier"; filename="magento'.time().'.csv"' . "\n";
  60.     $data .= 'Content-Type: text/plain' . "\n". "\n";
  61.     $data .= $csv . "\n";
  62.     $data .= "--" . $mime_boundary . "--" . "\n" . "\n"; // finish with two eol's!!
  63.     $params = array('http' => array(
  64.         'method' => 'POST',
  65.         'header' => 'Content-Type: multipart/form-data; boundary=' . $mime_boundary . "\n",
  66.         'content' => $data
  67.     ));
  68.     $ctx = stream_context_create($params);
  69.     /* if($ctx)
  70.      {
  71.              $response = @file_get_contents($destination, FILE_TEXT, $ctx);
  72.              if ($response)
  73.              {
  74.                      $result_fields=explode(',',$response);
  75.              }
  76.      }
  77.  */
  78.     if($ctx)
  79.     {
  80.         $response = @file_get_contents($destination, FILE_TEXT, $ctx);
  81.         if ($response)
  82.         {
  83.             $check = str_replace( ',', '', $response);
  84.             if (preg_match("/^[0-9]{10}/", $check)){
  85.                 $explode = explode(',', $response);
  86.                 $awb_model = new PackageModel();
  87.                 $awb_model->awb = $explode[2];
  88.                 $awb_model->id = str_replace(',', '', $APP->request->post->awb_id);
  89.                 $awb_model->doUpdateField('awb');
  90.  
  91.                 //catch the awb
  92.                 $view->awb = $explode[2];
  93.             }
  94.             else{
  95.                 // catch the errors
  96.                 $view->awb = $response;
  97.                 $view->awb_err = 1;
  98.             }
  99.         }
  100.         else
  101.         {
  102.             echo "no response";
  103.             exit;
  104.         }
  105.  
  106.     } else {
  107.         echo "can't create context";
  108.         //exit;
  109.     }
  110.  
  111.  
  112. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top