����JFIF��H�H����Exif��MM�*���� ��3����V�����3������3�(��������������������3�����403WebShell
403Webshell
Server IP : 74.208.127.88  /  Your IP : 216.73.216.169
Web Server : Apache/2.4.41 (Ubuntu)
System : Linux ubuntu 5.4.0-163-generic #180-Ubuntu SMP Tue Sep 5 13:21:23 UTC 2023 x86_64
User : www-data ( 33)
PHP Version : 7.4.3-4ubuntu2.29
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/html/goldencar/sae/application/salesFactura4.0S2/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/goldencar/sae/application/salesFactura4.0S2/pruebasOK2.php
<?php
ini_set('display_errors', 1);
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
require_once 'nusoap/nusoap.php';
include 'heredoc_txt.php';
session_start();

$method=$_POST['method'];
  $sell_id=$_POST['id'];
  $sale_id=$_POST['sale_id'];
 //datos del cliente
  $client_name= $_POST['client_name'];
  $client_rfc= $_POST['rfc'];
  $uso_cfdi= $_POST['uso_cfdi'];
  $FormaPago = $_POST['forma_id'];
  $notapdf = $_POST['note'];
  $client_id = $_POST['client_id'];
  
  
  $sale1= $_POST['sale_id'];
  
if(isset($sale1))
{		
		require_once ("../model/dbconn.php");
		require_once ("../model/pos.php");
			
			$posConfig = new pos();
			//impuesto general
			$impuestoBD = $posConfig->getByPreffix('imp-val')[1]['val'];
			//usuario multifacturas real
			$userMulti = $posConfig->getByPreffix('Usuario_Factura')[1]['val'];
			//pass multifacturas real
			$passMulti = $posConfig->getByPreffix('pass_fac')[1]['val'];
			//detalles
			$ArchCerDemo = $posConfig->getByPreffix('archivo_cer_demo')[1]['val'];
			$ArchKeyDemo = $posConfig->getByPreffix('archivo_key_demo')[1]['val']; 
			$settingsEmisor = $posConfig->getByPreffix('name_val')[1]['val']; 
			$settingsCP = $posConfig->getByPreffix('cp_val')[1]['val']; 
			$RegimenDemo = $posConfig->getByPreffix('Regimen_sat')[1]['val']; 
			
			$CodigoSatGenerico = $posConfig->getByPreffix('Sat_val')[1]['val']; 
			
			$settingsCodigoSat = $posConfig->getByPreffix('Sat_val')[1]['val']; 
			$settingsUnidadSat = $posConfig->getByPreffix('Sat_val_Unidad')[1]['val']; 
			$RFC_demo_Emisor = $posConfig->getByPreffix('rfc_val')[1]['val'];
			$RFC_nombre_Emisor = $posConfig->getByPreffix('name_val')[1]['val'];
			$PassDemoMulti= $posConfig->getByPreffix('Pass_Sat_demo')[1]['val'];
			$logo = $posConfig->getByPreffix('report_image')[1]['val']; 
			$emailPrincipal = $posConfig->getByPreffix('admin_email')[1]['val']; 
			
			//facturacion real SI(real)/NO(demo)
			$FacturacionReal = $posConfig->getByPreffix('demo_fac')[1]['val']; 
			//DATOS POST
			
			$client_name= $_POST['client_name'];
			$client_rfc= $_POST['rfc'];
			$client = new pos();
			$client_regimen = $client->getClientByRFC($client_rfc)[1]['phone'];
			$client_codigo = $client->getClientByRFC($client_rfc)[1]['country'];
			
			//buscar en la tabla clientes el rfc(ciudad) y el regimen(telefono)
			
			$uso_cfdi= $_POST['uso_cfdi'];
			$FormaPago = $FormaPago;
			$posForma= new pos();
			$FormaPago = $posForma->getFormakId($FormaPago)[1]['def'];
		
			//obtenemos sell_id
			$posSell=new pos();
			$sell = $posSell->getlistSell($sale1);
			$sell_id = $posSell->getlistSell($sale1)[1]['id']; 
			
			
			//folio de tabla facturacion
			$posFolioF = new pos();
			$FolioF = $posFolioF->getByFacturaMax();
			if($FolioF[1]['id'] > 0){
				$FolioFactura = $FolioF[1]['id'] + 1;
			}else{
				$FolioFactura = 1;
			}
			
			//NOTA EN FACTURA pdf
			 $notapdf = 'nota ';
			
			// Se desactivan los mensajes de debug
			//ejemplo factura cfdi 4.0
				// Se especifica la zona horaria
			date_default_timezone_set('America/Mexico_City');
				// Se especifica la version de CFDi 4.0
			$datos['version_cfdi'] = '4.0';
				// Credenciales de Timbrado
			$datos['PAC']['usuario'] = ''.$userMulti.'';
			$datos['PAC']['pass'] = ''.$passMulti.'';
			$datos['PAC']['produccion'] = ''.$FacturacionReal.'';

				$datos['conf']['cer'] = '../../../sdk2/certificados/'.$ArchCerDemo.'';
				$datos['conf']['key'] = '../../../sdk2/certificados/'.$ArchKeyDemo.'';
				$datos['conf']['pass'] = ''.$PassDemoMulti.'';
							

				//datos de Emisor
							$datos['emisor']['rfc'] = ''.$RFC_demo_Emisor.''; //RFC DE PRUEBA
							$datos['emisor']['nombre'] = "".$settingsEmisor."";  // EMPRESA DE PRUEBA
							$datos['emisor']['RegimenFiscal'] = ''.$RegimenDemo.'';

				// Datos del Receptor
							$datos['receptor']['UsoCFDI'] = $uso_cfdi;
							$datos['receptor']['rfc'] = $client_rfc;
							$datos['receptor']['nombre'] = $client_name;
							$datos['receptor']['DomicilioFiscalReceptor'] = $client_codigo;
							$datos['receptor']['RegimenFiscalReceptor'] = $client_regimen;

				// Se agregan los conceptos
					$operations=new pos();
							$operation1 = $operations->getOperations($sale1);
							//print_r($operation1[1]);

										$i=0;
													$impuesto=0;
													$subtotal=0;
													$subtotal0=0;
													$subtotal8=0;
													$subtotal16=0;
													$banderaCero = 1;
													foreach($operation1[1] as $operation){
															if($operation['item_name'] != null){
																
																$pos = new pos();
																$result = array();
																$query = $pos->getItem($operation['id_item']);
																$data = $query[1];
																$result['tax'] = $data['tax'];
																$result['type_tax'] = $data['type_tax'];
																
																	
																	if($result['tax'] == 8){
																		$price_sin = number_format($operation['price']/1.08,2);
																			 $price_sin = floatval(preg_replace('/[^\d.]/', '', $price_sin));
																	}elseif($result['tax'] == 16){
																			 $price_sin = number_format($operation['price']/1.16,2);
																			 $price_sin = floatval(preg_replace('/[^\d.]/', '', $price_sin));
																	}else{
																		$price_sin = number_format($operation['price'],2);
																			 $price_sin = floatval(preg_replace('/[^\d.]/', '', $price_sin));
																	}
															if($result['tax']==0 && $result['type_tax']=="Exento" ){		
																$datos['conceptos'][$i]['cantidad'] = $operation['qty'];
																$datos['conceptos'][$i]['unidad'] = $operation['unit'];
																$datos['conceptos'][$i]['ID'] = $operation['barcode'];
																$datos['conceptos'][$i]['descripcion'] =$operation['item_name'];
																$datos['conceptos'][$i]['valorunitario'] = $price_sin;
																$datos['conceptos'][$i]['importe'] = $price_sin*$operation['qty'];
																//'50211503' codigo sat
																$datos['conceptos'][$i]['ClaveProdServ'] = $CodigoSatGenerico;
																$datos['conceptos'][$i]['ClaveUnidad'] = 'H87';
																$datos['conceptos'][$i]['ObjetoImp'] = '02';

																$datos['conceptos'][$i]['Impuestos']['Traslados'][0]['Base'] = $price_sin*$operation['qty'];
																$datos['conceptos'][$i]['Impuestos']['Traslados'][0]['Impuesto'] = '002';
																$datos['conceptos'][$i]['Impuestos']['Traslados'][0]['TipoFactor'] = 'Exento';
																
																$subtotal0 = $subtotal0 + ($price_sin*$operation['qty']);
															}
															
															if($result['tax']==0){	
																$datos['conceptos'][$i]['cantidad'] = $operation['qty'];
																$datos['conceptos'][$i]['unidad'] = $operation['unit'];
																$datos['conceptos'][$i]['ID'] = $operation['barcode'];
																$datos['conceptos'][$i]['descripcion'] =$operation['item_name'];
																$datos['conceptos'][$i]['valorunitario'] = $price_sin;
																$datos['conceptos'][$i]['importe'] = $price_sin*$operation['qty'];
																$datos['conceptos'][$i]['ClaveProdServ'] = $CodigoSatGenerico;
																$datos['conceptos'][$i]['ClaveUnidad'] = 'H87';
																$datos['conceptos'][$i]['ObjetoImp'] = '02';

																$datos['conceptos'][$i]['Impuestos']['Traslados'][0]['Base'] = $price_sin*$operation['qty'];
																$datos['conceptos'][$i]['Impuestos']['Traslados'][0]['Impuesto'] = '002';
																$datos['conceptos'][$i]['Impuestos']['Traslados'][0]['TipoFactor'] = 'Tasa';
																$datos['conceptos'][$i]['Impuestos']['Traslados'][0]['TasaOCuota'] = '0.000000';
																$datos['conceptos'][$i]['Impuestos']['Traslados'][0]['Importe'] = 0.00;
																
																//agregamos el producto tasa cero
																$valor0 = $price_sin*$operation['qty'];
																$valor = 0.00;
																$banderaCero=2;
																
																$subtotal0 = $subtotal0 + ($price_sin*$operation['qty']);
															}

															//PRODUCTO CON TASA 16 o 8
															if($result['tax']==8){	
																$datos['conceptos'][$i]['cantidad'] = $operation['qty'];
																$datos['conceptos'][$i]['unidad'] = $operation['unit'];
																$datos['conceptos'][$i]['ID'] = $operation['barcode'];
																$datos['conceptos'][$i]['descripcion'] =$operation['item_name'];
																$datos['conceptos'][$i]['valorunitario'] = $price_sin;
																$datos['conceptos'][$i]['importe'] = $price_sin*$operation['qty'];
																$datos['conceptos'][$i]['ClaveProdServ'] = $CodigoSatGenerico;
																$datos['conceptos'][$i]['ClaveUnidad'] = 'H87';
																$datos['conceptos'][$i]['ObjetoImp'] = '02';
																
																$valor1 = number_format(($price_sin*$operation['qty'])*0.080000,2);
																$valor1 = floatval(preg_replace('/[^\d.]/', '', $valor1));
																$valor0 = number_format($price_sin*$operation['qty'],2);

																$datos['conceptos'][$i]['Impuestos']['Traslados'][0]['Base'] = $price_sin*$operation['qty'];
																$datos['conceptos'][$i]['Impuestos']['Traslados'][0]['Impuesto'] = '002';
																$datos['conceptos'][$i]['Impuestos']['Traslados'][0]['TipoFactor'] = 'Tasa';
																$datos['conceptos'][$i]['Impuestos']['Traslados'][0]['TasaOCuota'] = '0.080000';
																$datos['conceptos'][$i]['Impuestos']['Traslados'][0]['Importe'] = $valor1;
																$impuesto = number_format($impuesto + $valor1,2);

																$subtotal8 = $subtotal8 + ($price_sin*$operation['qty']);
															}
															
															if($result['tax']==16){	
																$datos['conceptos'][$i]['cantidad'] = $operation['qty'];
																$datos['conceptos'][$i]['unidad'] = $operation['unit'];
																$datos['conceptos'][$i]['ID'] = $operation['barcode'];
																$datos['conceptos'][$i]['descripcion'] =$operation['item_name'];
																$datos['conceptos'][$i]['valorunitario'] = $price_sin;
																$datos['conceptos'][$i]['importe'] = $price_sin*$operation['qty'];
																$datos['conceptos'][$i]['ClaveProdServ'] = $CodigoSatGenerico;
																$datos['conceptos'][$i]['ClaveUnidad'] = 'H87';
																$datos['conceptos'][$i]['ObjetoImp'] = '02';
																
																$valor1 = number_format(($price_sin*$operation['qty'])*0.160000,2);
																$valor1 = floatval(preg_replace('/[^\d.]/', '', $valor1));
																$valor0 = number_format($price_sin*$operation['qty'],2);

																$datos['conceptos'][$i]['Impuestos']['Traslados'][0]['Base'] = $price_sin*$operation['qty'];
																$datos['conceptos'][$i]['Impuestos']['Traslados'][0]['Impuesto'] = '002';
																$datos['conceptos'][$i]['Impuestos']['Traslados'][0]['TipoFactor'] = 'Tasa';
																$datos['conceptos'][$i]['Impuestos']['Traslados'][0]['TasaOCuota'] = '0.160000';
																$datos['conceptos'][$i]['Impuestos']['Traslados'][0]['Importe'] = $valor1;
																$impuesto = number_format($impuesto + $valor1,2);

																$subtotal16 = $subtotal16 + ($price_sin*$operation['qty']);
															}
																$subtotal = $subtotal + ($price_sin*$operation['qty']);
																$total = $subtotal +  $impuesto ; 
																//echo "-------------------------------";
																//echo $valor1;
																$i=$i+1;	
														}
														
														if($impuesto > 0){			
															// Se agregan los Impuestos SOLO EL QUE TIENE TASA >0 16 u 8
															if($result['tax']==8){	
																$datos['impuestos']['translados'][0]['Base'] = $subtotal8;
																$datos['impuestos']['translados'][0]['impuesto'] = '002';
																$datos['impuestos']['translados'][0]['tasa'] = '0.080000';
																$datos['impuestos']['translados'][0]['importe'] = $impuesto;
																$datos['impuestos']['translados'][0]['TipoFactor'] = 'Tasa';
															}
															if($result['tax']==16){	
																$datos['impuestos']['translados'][0]['Base'] = $subtotal16;
																$datos['impuestos']['translados'][0]['impuesto'] = '002';
																$datos['impuestos']['translados'][0]['tasa'] = '0.160000';
																$datos['impuestos']['translados'][0]['importe'] = $impuesto;
																$datos['impuestos']['translados'][0]['TipoFactor'] = 'Tasa';
															}
																//tasa cero
																if( $banderaCero == 2){
																	$datos['impuestos']['translados'][1]['Base'] = $subtotal0;
																	$datos['impuestos']['translados'][1]['impuesto'] = '002';
																	$datos['impuestos']['translados'][1]['tasa'] = '0.000000';
																	$datos['impuestos']['translados'][1]['importe'] = 0.00;
																	$datos['impuestos']['translados'][1]['TipoFactor'] = 'Tasa';
																}
														}else{
																$datos['impuestos']['translados'][1]['Base'] = $subtotal0;
																$datos['impuestos']['translados'][1]['impuesto'] = '002';
																$datos['impuestos']['translados'][1]['tasa'] = '0.000000';
																$datos['impuestos']['translados'][1]['importe'] = 0.00;
																$datos['impuestos']['translados'][1]['TipoFactor'] = 'Tasa';
															}
														
													}
														//total de impuestos
														$impuesto = floatval(preg_replace('/[^\d.]/', '', $impuesto));
														$datos['impuestos']['TotalImpuestosTrasladados'] = $impuesto;

											// Datos de la Factura
											$datos['factura']['condicionesDePago'] = 'CONTADO';
											$datos['factura']['descuento'] = '0.00';
											$datos['factura']['fecha_expedicion'] = date('Y-m-d\TH:i:s', time() - 3600);
											$datos['factura']['folio'] = $FolioFactura;
											$datos['factura']['forma_pago'] =  $FormaPago;
											$datos['factura']['LugarExpedicion'] = $settingsCP;
											$datos['factura']['metodo_pago'] = 'PUE';
											$datos['factura']['moneda'] = 'MXN';
											$datos['factura']['serie'] = 'A';
											$datos['factura']['subtotal'] =$subtotal;
											$datos['factura']['tipocambio'] = 1;
											$datos['factura']['tipocomprobante'] = 'I';
											$datos['factura']['total'] = $subtotal + $impuesto;
											$datos['factura']['Exportacion'] = '01';
											$datos['factura']['RegimenFiscal'] = ''.$RegimenDemo.'';

												//asignamos los valores para insertarlos en la tabla subtotal e impuestos
														$subtotal1 = $subtotal;
														$impuesto1 = $impuesto;
;			/*			
			echo "/n";
			echo "<pre>";
			//print_r($datos);
			echo  "------------------------------------------------------------->";
			echo "</pre>";
			//die;
		*/
				
			# CREACIÓN DEL OBJETO DEL API DE CONEXION
		try{
			$url = 'https://dev.timbradorxpress.mx/ws/servicio.do?wsdl'; // EndPoint del servicio
			
			generateTxt($datos, $uuid=uniqid('', true));}
		catch (Exception $e){
			echo "Error: ";
			echo $e->getMessage();
			
		}
			$objConexion = new SoapClient($url); // Creación del objeto de conexión
			/*
				$txtB64 = base64_encode( file_get_contents('rsc/ejemplo_cfdi.txt') );
				$keyPEM = file_get_contents('rsc/CSD_EKU9003173C9_key.pem');
				$cerPEM = file_get_contents('rsc/CSD_EKU9003173C9_cer.pem');
				$plantilla = '1';
				$logoB64 = base64_encode( file_get_contents('rsc/logo.png') );
				echo $objConexion->operacion_timbrarTXT2($apikey, $txtB64, $keyPEM, $cerPEM, $plantilla, $logoB64);
			
			*/
			# PARÁMETROS DEL MÉTODO
			$apikey = 'b6ee27710a6747beb96bc51fbe047dcf'; // Credencial o apikye del servicio pruebas
			$arc_JSON2 = file_get_contents($uuid.'.txt'); //Mandamos a traer el archivo TXT
			$jsonBase64 = base64_encode($arc_JSON2);
			
			
			//ruta CERTIFICADOS NAVA
			$keyPEM = file_get_contents('rsc_txt/NAVA/'.$ArchKeyDemo.''); // Archivo .key en formato PEM
			$cerPEM = file_get_contents('rsc_txt/NAVA/'.$ArchCerDemo.''); // Archivo .cer en formato PEM
			
			
			//ruta CETIFICADOS 16%
			//$keyPEM = file_get_contents('rsc/CSD_EKU9003173C9_key.pem');
			//$cerPEM = file_get_contents('rsc/CSD_EKU9003173C9_cer.pem');
			
			
			$plantilla = '1'; //Indicamos el numero de plantilla para la representación grafica PDF
			$logo = file_get_contents('rsc_txt/logo34_1.jpg');
			$logo64 = base64_encode($logo);
			//Consumimos el metodo JSON2 del Servicio WEB
			$res = $objConexion->timbrarTXT2($apikey, $jsonBase64, $keyPEM, $cerPEM, $plantilla, $logo64);
			
			
			//NO CONSUME TIMBRES
			$saldo = $objConexion->consultarCreditosDisponibles($apikey);
			/*
				echo 'code: ' . $saldo->code . '<br>';
				echo 'message: ' . $saldo->message . '<br><br>';
			*/
			
			# RESPUESTA DEL SERVICIO
			//echo 'code: ' . $res->code . '<br>';
			//echo 'message: ' . $res->message . '<br><br>';

			/*
			200 - Solicitud procesada con éxito.
			307 - El CFDI contiene un timbre previo.
			 */

				$codigo= $res->code;
				$name_codigo= $res->message;	
				$id=$sell_id;
				
								
//Cuando sea codigo "200" o "307"(timbre duplicado) se guardaran los archivos XML y PDF
if ($res->code == '200' ) {
	
				 $mail=$posConfig->getByPreffix('admin_email')[1]['val']; ;
				 $rfc=$client_rfc;
				 $sell_id=$id;
				 $sale_id=$sale1;
				 $total=$subtotal + $impuesto;
				 $iva=$impuestoBD;
				 $name=$client_name;
				 $user_id =  $_POST["user_id"];
				
				$pos = new pos();
				$insert = $pos->saveFacturaSell($mail,$uuid,$rfc,$sell_id,$sale_id,$subtotal,$impuesto,$total,$iva,$name,$user_id);
				
				//print_r($insert);
				
				//validamos que exista el registro de la factura
				if(isset($insert[1])){
					
					$retval['result'] = $insert[0];
					$retval['error'] = $insert[1];
					//$retval['xsale_id'] = $insert[2];
				}else{
					$retval['result'] = 0;
					$retval['xsale_id'] = "1001";
				}
				
				//echo $retval['result'];
				
				if($retval['result'] == 1){
					
					//print "<script>window.location='./basica11.php?uuid=$uuid&id=$sell_id&rfc=$client_rfc&name=$client_name&sale1=$sale_id';</script>";
					//ERROR al registrar en la base de datos
					$codigo= $res->code;
					$name_codigo= $res->message;
					
					$respuesta=$uuid;
					$result['result'] = true;
					$result['respuesta'] = $respuesta;
					$result['codigo_error'] = $codigo;
					$result['error'] = $name_codigo;
					
					echo json_encode($result);
				
				}else{
					
					//ERROR al registrar en la base de datos
					$codigo= $res->code;
					$name_codigo= $res->message;
					
					$respuesta = "Error al guardar Registro en Base de Datos, Reporte a Sistemas, para registro , y obtener XML,PDF";
					$result['respuesta'] = $respuesta;
					$result['codigo_error'] = $codigo;
					$result['error'] = $name_codigo;
					$result['result'] = false;	

					echo json_encode($result);
				
				}
				// Se crea el objeto de la respuesta del Servicio.
				$dataOBJ = json_decode($res->data);
				//definimos los nameSpace para remplazarlos
				$namespaces_remplazo = array(
					'cfdi:', 'xmlns:', 'xsi:', 'oxml:', 'ns3:', 'ns9:', 'ns8:',
					'S:', 'dig:', 'res:', 'wsu:', 'wsse:', 'ns3:', 'wsu:', 'soapenv:', 'env:',
					'oxml:', '<![CDATA[', ']]>', 'tfd:', 'divisas:', 'ine:', 'iedu:', 'detallista:', 'ventavehiculos:', 'cce11:', 'leyendasFisc:',
					'aerolineas:', 'donat:', 'notariospublicos:', 'servicioparcial:', 'vehiculousado:', 'detallista:', 'terceros:', 'implocal:', 'pfic:');
				//Se realiza el remplazo de los nameSpace del atributo XML
				$xmlclean = str_replace($namespaces_remplazo, "", $dataOBJ->xml);
				$xml = simplexml_load_string($xmlclean);
				$json = json_encode($xml);
				$obj = json_decode($json);
				//recorremos el objeto de datos para extraer la informacion del atributo UUID
				$uuid = $obj->{'Complemento'}->{'TimbreFiscalDigital'}->{'@attributes'}->{'UUID'};

				// Creamos los archivos con la extencion .xml y .pdf de la respuesta obtenida del parametro "date"
				file_put_contents('../../../../timbrados/cfdi_factura_' . $sale_id . '.xml', $dataOBJ->xml); //archivo XML
				file_put_contents('../../../../timbrados/cfdi_factura_' . $sale_id . '.pdf', base64_decode($dataOBJ->pdf)); //Archivo PDF
			
			
	}else{
		//eliminamos la venta generada
		
		
		//enviamos el error que se registro 
				$codigo= $res->code;
				$name_codigo= $res->message;	
			
			$respuesta = "Error codigo de pack";
			$result['respuesta'] = $respuesta;
			$result['codigo_error'] = $codigo;
			$result['error'] = $name_codigo;
			$result['result'] = false;
			
				echo json_encode($result);
	}
		
			
}	
			
?>

 


Youez - 2016 - github.com/yon3zu
LinuXploit