Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (isset($APP->request->post->generate_awb)) {
- echo $APP->request->post->cont_colector;
- $username= 'clienttest';
- $client_id='7032158';
- $user_pass ='testing';
- $service = $APP->request->post->serviciu;
- $envelopes = $APP->request->post->plic;
- $parcels = $APP->request->post->colete;
- $weight = $APP->request->post->greutate;
- $payment = $APP->request->post->plata;
- $reimbursement = $APP->request->post->ramburs;
- $reimbursement_payment = $APP->request->post->ramburs_colet;
- $declared_value= $APP->request->post->val_colet;
- $contactperson = $APP->request->post->pers_contact;
- $observations = $APP->request->post->obs;
- $content = $APP->request->post->content;
- $recipient = 'test';
- $contact_person = $APP->request->post->pers_contact;;
- $phone=$APP->request->post->telefon;
- $fax ='';
- $email='';
- $county = $APP->request->post->judet;
- $town = $APP->request->post->localitate;
- $street = $APP->request->post->adresa;
- $street_no = '';
- $zip_code = '';
- $block='';
- $entrance='';
- $floor='';
- $flat='';
- $height='';
- $width='';
- $length='';
- $refund='';
- $cost_center='';
- $options='A';
- $packing='';
- $personal_data='';
- $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
- {$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}";
- $destination = "https://www.selfawb.ro/import_awb_integrat.php";
- $data = '';
- $mime_boundary=md5(time());
- $data .= '--' . $mime_boundary . "\n";
- $data .= 'Content-Disposition: form-data; name="username"' . "\n" . "\n";
- $data .= $username . "\n";
- $data .= '--' . $mime_boundary . "\n";
- $data .= 'Content-Disposition: form-data; name="client_id"' . "\n" . "\n";
- $data .= $client_id . "\n";
- $data .= '--' . $mime_boundary . "\n";
- $data .= 'Content-Disposition: form-data; name="user_pass"' . "\n" . "\n";
- $data .= $user_pass . "\n";
- $data .= '--' . $mime_boundary . "\n";
- $data .= 'Content-Disposition: form-data; name="fisier"; filename="magento'.time().'.csv"' . "\n";
- $data .= 'Content-Type: text/plain' . "\n". "\n";
- $data .= $csv . "\n";
- $data .= "--" . $mime_boundary . "--" . "\n" . "\n"; // finish with two eol's!!
- $params = array('http' => array(
- 'method' => 'POST',
- 'header' => 'Content-Type: multipart/form-data; boundary=' . $mime_boundary . "\n",
- 'content' => $data
- ));
- $ctx = stream_context_create($params);
- /* if($ctx)
- {
- $response = @file_get_contents($destination, FILE_TEXT, $ctx);
- if ($response)
- {
- $result_fields=explode(',',$response);
- }
- }
- */
- if($ctx)
- {
- $response = @file_get_contents($destination, FILE_TEXT, $ctx);
- if ($response)
- {
- $check = str_replace( ',', '', $response);
- if (preg_match("/^[0-9]{10}/", $check)){
- $explode = explode(',', $response);
- $awb_model = new PackageModel();
- $awb_model->awb = $explode[2];
- $awb_model->id = str_replace(',', '', $APP->request->post->awb_id);
- $awb_model->doUpdateField('awb');
- //catch the awb
- $view->awb = $explode[2];
- }
- else{
- // catch the errors
- $view->awb = $response;
- $view->awb_err = 1;
- }
- }
- else
- {
- echo "no response";
- exit;
- }
- } else {
- echo "can't create context";
- //exit;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement