function GetNDFLldf() { //Set Variables //$host = '54.83.44.110'; $host = $_SESSION['vista']; //$username = '******'; $username = $_SESSION['sshusr']; $password = ''; $login = '******'; //$loginpass = '******'; $loginpass = $_SESSION['sshpwd']; $csession = 'csession cache355'; $ssh = new Net_SSH2($host); if (!$ssh->login($username, $password)) { exit('Login Failed'); } $ssh->write("{$login}\r"); $ssh->write("{$loginpass}\r"); sleep(3); $ssh->write("CPRS1234\r"); $ssh->write("CPRS4321\$\r"); sleep(3); $ssh->write("\r"); $ssh->write("FM\r"); $ssh->write("Other\r"); $ssh->write("RX\r"); $ssh->write("PSN\r"); $ssh->write("RPRT\r"); $ssh->write("LDF\r"); $countr = 0; while ($countr <= 1000) { $ssh->write("\r"); $countr++; } sleep(1); //Set SSH Timeout $ssh->setTimeout(1); //Read Results $SSHresults = $ssh->read(); $txtremove = array("[H[J[2J[H LOCAL DRUG LIST (ALPHABETI\nC)# Not on National Formulary\n R National Formulary Restriction\n \nLOCAL DRUG NAME INACTIVE DEA\n \n NDC DATE"); $SSHresultsNew = str_replace($txtremove, "", $SSHresults); $myFile = writeDrugFile($SSHresultsNew); $lineNum = 1; $count = 1; while ($count <= 194) { delLineFromFile($myFile, $lineNum); $count++; } $lineNum2 = 12741; $count2 = 1; while ($count2 <= 151) { delLineFromFile($myFile, $lineNum2); $count2++; } //Delete SQL $Dquery = "DELETE FROM LookUp WHERE Lookup_Type = 2"; $DelDrugs = sqlsrv_query($conn, $Dquery); $str = file_get_contents($myFile); $array = preg_split('/[\\n\\r]+/', $str); foreach ($array as $i => $value) { $prefix = " "; $val = str_startswith($value, $prefix); if ($val === true) { } else { $prefix = "ZZ"; $val = str_startswith($value, $prefix); if ($val === true) { } else { include "dbitcon.php"; //$query = "INSERT INTO COMS_Drugs (Drugs) VALUES ('$value')"; $query = "INSERT INTO LookUp (Lookup_Type,Name,Description) VALUES (2,'{$value}','NLM')"; $postDrugs = sqlsrv_query($conn, $query); } } } file_put_contents($myFile, "{$str}"); echo "Text file created and database entries updated in Lookup table for LookupType 2."; }
$cont++; $cadena_buscada = $ipsel; $linea = fgets($file); $posicion_coincidencia = strpos($linea, $cadena_buscada); if (!is_bool($posicion_coincidencia)) { $a = "no exixte"; break; } ////IF } //whileee if (is_bool($posicion_coincidencia)) { die($_REQUEST['data']); } $linea = $cont; if (!delLineFromFile($squid, $linea)) { $resp = array(); $resp["evento"] = $action; $resp["respuesta"] = "error_archivo"; echo json_encode($resp); } else { $clsSql = new Conexion(); $clsSql->abrir_conexion(); $usuarioid = $_SESSION['id_usuario']; $ipusuario = get_client_ip(); $sql = "INSERT INTO SYSADMIN.auditoria (usuario_id, accion,descripcion, ip_origen) VALUES ('{$usuarioid}', 'Eliminar ACL SQUID','({$ipsel}) nombre->{$nombre} ','{$ipusuario}');"; $clsSql->consulta_bd($sql); $clsSql->cerrar_conexion(); $resp = array(); $resp["evento"] = $action; $resp["respuesta"] = "Eliminado de la ACL de <strong>SQUID</strong> Exitosamente";
if (!is_bool($posicion_coincidencia)) { break; } ////IF } //whileee if (is_bool($posicion_coincidencia)) { die($_REQUEST['id_red']); } $linea = $cont; //echo $linea; //fclose($file); delLineFromFile($f, $linea); delLineFromFile($f, $linea); delLineFromFile($f, $linea); delLineFromFile($f, $linea); if (!delLineFromFile($f, $linea)) { $resp = array(); $resp["evento"] = $action; $resp["respuesta"] = "no se puede abrir el archivo"; echo json_encode($resp); } $resp = array(); $resp["evento"] = $action; $resp["respuesta"] = "eliminado"; exec("sudo /etc/init.d/isc-dhcp-server restart"); echo json_encode($resp); break; default: break; }
function check_localstorage($token) { global $cache_file; $hashs = file($cache_file); if (count($hashs) !== 0) { $i = 0; foreach ($hashs as $hash) { $hash = explode(" ", $hash); $hash[2] = str_replace("\n", "", $hash[2]); if (time() - $hash[0] >= 2592000) { delLineFromFile($cache_file, $i); continue; } if ($token === $hash[1]) { delLineFromFile($cache_file, $i); $_SESSION['username'] = $hash[2]; $_SESSION['isauth'] = 1; genToken(); return TRUE; } $i++; } } return FALSE; }