actualizacion proyecto msisdn

parent c0afb264
<?php
/**
* ###################
* 1-INICIO SESION PHP
* ###################
*
*/
if (session_id() == '' || !isset($_SESSION)) {
session_start();
}
/**
* ###################
* 2-INICIO VARIABLES PHP
* ###################
*
*/
$status_code = null;
$desc = '';
$xmlOutput = '';
$xmlDesc = '';
$output = '';
/**
* ###################
* 3-TRATAMIENTO URL Y XML PHP
* ###################
*
*/
$params = urldecode($_SERVER['QUERY_STRING']);
$url = "http://vpwproxy.vas.entelpcs.cl/vpw.php?#PARAMETROS";
$url = str_replace('#PARAMETROS', $params, $url);
$msisdn = $_POST["msisdn"];
$xml = "<?xml version='1.0' encoding='UTF-8'?><unsubscribe><entry>569" . $msisdn . "</entry></unsubscribe>";
/**
* ###################
* 4-LLAMADO A CURL
* ###################
*
*/
try {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
$output = curl_exec($ch);
$xmlDesc = $output;
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$xmlOutput = simplexml_load_string($output);
if (isset($xmlOutput->error)) {
$desc = (string) $xmlOutput->error;
} else if (isset($xmlOutput->info)) {
$desc = (string) $xmlOutput->info;
}
if ($desc == "") {
switch ($status_code) {
case 300:
$desc = "No fue posible consultar plan.";
break;
case 403:
$desc = "IP no autorizada.";
break;
}
}
} catch (\Exception $e) {
$status_code = null;
$desc = null;
}
/**
* ###################
* 5-RESULTADO CURL
* ###################
*
*/
//echo '{"desc" : "'.$desc.'", "status_code" : '.$status_code.', "callbackUrl" : "'.$url.'"}';
echo "$desc|$status_code|$xmlDesc";
......@@ -57,7 +57,7 @@ if(empty($params)){
write_log("Retorno con msisdn", "INFO");
write_log($urlRetorno, "INFO");
write_log($msisdn, "INFO");
$msisdn = substr($msisdn, 3);
$msisdn = substr($msisdn, 2);
header("Location: http://new.entelmusic.cl?msisdn=$msisdn");
die();
}
......@@ -93,7 +93,7 @@ if (!$check) {
*/
if (isset($_COOKIE['User-Identity-Forward-msisdn']) && $_COOKIE['User-Identity-Forward-msisdn'] != "") {
$msisdn = substr($_COOKIE['User-Identity-Forward-msisdn'], -11);
$msisdn = substr($_COOKIE['User-Identity-Forward-msisdn'], -9);
write_log("COOKIE identificada", "INFO");
write_log("$msisdn obtenido", "INFO");
header("Location: http://new.entelmusic.cl?msisdn=$msisdn");
......
<?php
/**
* ###################
* 1-INICIO SESION PHP
* ###################
*
*/
if (session_id() == '' || !isset($_SESSION)) {
session_start();
}
/**
* ###################
* 2-INICIO VARIABLES PHP
* ###################
*
*/
$status_code = null;
$desc = '';
$xmlOutput = '';
$xmlDesc = '';
$output = '';
/**
* ###################
* 3-TRATAMIENTO URL Y XML PHP
* ###################
*
*/
$params = urldecode($_SERVER['QUERY_STRING']);
$url = "http://vpwproxy.vas.entelpcs.cl/vpw.php?#PARAMETROS";
$url = str_replace('#PARAMETROS', $params, $url);
$msisdn = $_POST["msisdn"];
$xml = "<?xml version='1.0' encoding='UTF-8'?><subscribe><entry>569" . $msisdn . "</entry></subscribe>";
/**
* ###################
* 4-LLAMADO A CURL
* ###################
*
*/
try {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
$output = curl_exec($ch);
$xmlDesc = $output;
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$xmlOutput = simplexml_load_string($output);
if (isset($xmlOutput->error)) {
$desc = (string) $xmlOutput->error;
} else if (isset($xmlOutput->info)) {
$desc = (string) $xmlOutput->info;
}
if ($desc = "") {
switch ($status_code) {
case 300:
$desc = "No fue posible consultar plan.";
break;
case 402:
$desc = "El movil no tiene saldo.";
break;
case 501:
$desc = "Fallo en la configuracioon de validacion.";
break;
case 302:
$desc = "El movil ya esta agendado.";
break;
case 415 :
$desc = "El movil no es compatible.";
break;
case 410:
$desc = "El movil no tiene perfil compatible";
break;
}
}
} catch (\Exception $e) {
$status_code = null;
$desc = null;
}
/**
* ###################
* 5-RESULTADO CURL
* ###################
*
*/
//echo '{"desc" : "'.$desc.'", "status_code" : '.$status_code.', "callbackUrl" : "'.$url.'"}';
echo "$desc|$status_code|$xmlDesc";
......@@ -45,7 +45,7 @@ class EntelVPW {
);
$xml = "<?xml version='1.0' encoding='UTF-8'?><subscribe><entry>569" . $msisdn . "</entry></subscribe>";
$xml = "<?xml version='1.0' encoding='UTF-8'?><subscribe><entry>56" . $msisdn . "</entry></subscribe>";
$url = self::URL_EXTERNAL_VPW_SUSCRIBIR;
$url = str_replace('#PARAMETROS', http_build_query($params), $url);
......@@ -68,9 +68,15 @@ class EntelVPW {
curl_close($ch);
$log->debug('Retorno status a suscribir externo:' . $status_code_suscribir . ' | desc:' . $output);
$data = explode("|", $output);
$status_code = $data[1];
$desc = $data[0];
$xmlDesc = $data[2];
if(count($data) > 1){
$status_code = $data[1];
$desc = $data[0];
$xmlDesc = $data[2];
}else{
$status_code = 0;
$desc = "";
$xmlDesc = "";
}
} catch (\Exception $e) {
$log->err(' Error al suscribir. url:' . $url . ' .Exception: ' . $e);
$status_code = null;
......@@ -119,7 +125,7 @@ class EntelVPW {
'code' => $lista->getLisCode()
);
$xml = "<?xml version='1.0' encoding='UTF-8'?><unsubscribe><entry>569" . $msisdn . "</entry></unsubscribe>";
$xml = "<?xml version='1.0' encoding='UTF-8'?><unsubscribe><entry>56" . $msisdn . "</entry></unsubscribe>";
$url = self::URL_EXTERNAL_VPW_DESUSCRIBIR;
$url = str_replace('#PARAMETROS', http_build_query($params), $url);
......@@ -141,9 +147,15 @@ class EntelVPW {
curl_close($ch);
$log->debug('Retorno status a suscribir externo:' . $status_code_desuscribir . ' | desc:' . $output);
$data = explode("|", $output);
$status_code = $data[1];
$desc = $data[0];
$xmlDesc = $data[2];
if(count($data) > 1){
$status_code = $data[1];
$desc = $data[0];
$xmlDesc = $data[2];
}else{
$status_code = 0;
$desc = "";
$xmlDesc = "";
}
} catch (\Exception $e) {
$log->err(' Error al desuscribir. url:' . $url . ' .Exception: ' . $e);
$status_code = null;
......
......@@ -31,7 +31,7 @@ class Utiles {
}
public static function isMsisdn($msisdn) {
if (strlen($msisdn) != 8 || !is_numeric($msisdn)) {
if (strlen($msisdn) != 9 || !is_numeric($msisdn)) {
return false;
} else {
return true;
......@@ -40,7 +40,7 @@ class Utiles {
public static function formatMsisdnSpecial($msisdn) {
if (preg_match("/^[0-9]+$/", $msisdn) && strlen($msisdn) == 8) {
if (preg_match("/^[0-9]+$/", $msisdn) && strlen($msisdn) == 9) {
// if(is_numeric($msisdn) && strlen($msisdn) == 8){
return $msisdn;
}
......
......@@ -16,7 +16,7 @@
<form class="form-horizontal" action="/" method="post">
<div class="form-group">
<div class="col-md-12">
<input class="form-control focused" id="msisdn" name="msisdn" pattern=".{8,8}" required title="Debe ingresar 8 números" type="text" placeholder="Ej:74867425">
<input class="form-control focused" id="msisdn" name="msisdn" pattern=".{9,9}" required title="Debe ingresar 9 números" type="text" placeholder="Ej:974867425">
</div>
</div>
</form>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment