elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Rompecabezas de Bitcoin, Medio millón USD en premios


  Mostrar Temas
Páginas: 1 2 3 [4] 5 6 7 8 9 10 11 12 13
31  Programación / Programación C/C++ / Uploader (WININET C++ ftp). Como subo un archivo? en: 5 Septiembre 2013, 18:00 pm
Este codigo consigue subir el archivo a un ftp que monte en mi pc, pero al probarlo con
Hostinger no hace nada...

Alguna explicacion logica?

Código:

#include "string.h"

#include <iostream>
#include <windows.h>
#include <wininet.h>
using namespace std;
#pragma comment(lib,"Wininet.lib")

#include <windows.h>

#include <iostream>
#include <fstream>
#define ID_MYAPP 1
using namespace std;
long lFileSize = 0;
long nSumBytes = 0;
void GetFileName (char* szSource)
{
 char* ptr;
 
 for (ptr = &szSource [strlen (szSource)]; *ptr != '\\'; ptr--);
 
 ptr++;
 int i;
 for (i = 0; *ptr != '\0';ptr++,i++)
szSource[i] = *ptr;
 
 szSource [i] = '\0';
}
int main (int argc, char* argv [])
{

 cout << "File Uploading Utility :- " << endl;
 HINTERNET hInternet = NULL, hConnection = NULL;
 hInternet = InternetOpen(L"Title", 0, NULL, NULL, 0);
 if (hInternet == NULL)
 {
cout << "Error in opening connection" ;

return 0;
 }
 hConnection = InternetConnect (hInternet, L"31.170.165.195", 21, L"usuario", L"password", INTERNET_SERVICE_FTP, INTERNET_FLAG_ASYNC, ID_MYAPP);

 if (hConnection != NULL)
 {
cout << "Connection Established\n";
 }
 else
 {
InternetCloseHandle(hInternet);
 }
 HINTERNET hFile = NULL;
  hFile = FtpOpenFile(hConnection, L"\\archivo remoto", GENERIC_WRITE, FTP_TRANSFER_TYPE_BINARY, 0);
 
 
 HANDLE hLocalFile = NULL;
 hLocalFile = CreateFile (L"archivo local", GENERIC_READ , 0, NULL,
 OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
 if (hLocalFile == INVALID_HANDLE_VALUE) {
cout << "Please check the file name and path" << endl;
return 0;
 }
 
 lFileSize = GetFileSize (hLocalFile, NULL) ;
 char *inBuffer = new char [lFileSize];
 BOOL bResult;
 DWORD nBytesRead;
 DWORD nBytesToReadWrite = 512; //lFileSize;
 DWORD dwError;
 DWORD nBytesWritten = 0;
 DWORD nBytesLeft = lFileSize;
 do
 {
if (ReadFile(hLocalFile, inBuffer, nBytesToReadWrite, &nBytesRead, NULL))
{
nSumBytes = nSumBytes + nBytesRead;
bResult = InternetWriteFile (hFile, inBuffer, (nBytesToReadWrite >= nBytesLeft ? nBytesLeft : nBytesToReadWrite), &nBytesWritten);
nBytesLeft = lFileSize - nSumBytes;
cout << "Uploading : " << (nSumBytes * 100) / (lFileSize) << "% Completed" << "\r";
}
else
{
dwError = GetLastError ();
}
 } while (nSumBytes != lFileSize);
 if (nSumBytes == lFileSize)
cout << "File uploaded successfully" << endl;
 CloseHandle(hLocalFile);
 InternetCloseHandle (hFile);
 InternetCloseHandle (hConnection);
 InternetCloseHandle (hInternet);
 system("pause");
 return 0;
}
32  Programación / Programación C/C++ / Aver si podeis ayudar con este codigo: Wininet ftp en: 5 Septiembre 2013, 02:58 am
Me vendria bien una mano....
No lee el archivo con InternetReadFile.


Código:





void main()
{
 

    HINTERNET hSession = InternetOpen(L"WinInet Progress Sample",
                                       INTERNET_OPEN_TYPE_DIRECT,
                                      NULL,
                                      NULL,
                                      INTERNET_FLAG_PASSIVE);
   


HINTERNET hConnection = InternetConnect(hSession,L"LESCOMEDIENSPLUS.BESABA.COM",  // Server
                                            21,
                                            L"u115059645",     // Username
                                            L"toni12883",     // Password
                                            INTERNET_SERVICE_FTP,
                                            1,        // Synchronous
                                            NULL);    // No Context


// Download a file
HINTERNET hTransfer = NULL;


HANDLE hFileDownload = NULL;
TCHAR tchName[MAX_PATH] = TEXT("public_html\\test.sql");

// Open the transfer
hTransfer = FtpOpenFile(hConnection, tchName, GENERIC_READ,
   FTP_TRANSFER_TYPE_ASCII, 0);

if (hTransfer == INVALID_HANDLE_VALUE)
{
printf("Unable to open remote File");
system("pause");
return;
}


// Ok, the file transfer is active. Create a new file to write to
hFileDownload = CreateFile(TEXT("c:\\index.txt"), GENERIC_WRITE, FILE_SHARE_READ,
   NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);



if (hFileDownload == INVALID_HANDLE_VALUE)
{
printf("Unable to open Destination File");
return;
}











// Looks like everything's ok, so use InternetReadFile to download
// the file
char data_from_url[4096];
   DWORD NumberOfBytesRead = 0;
   while(InternetReadFile(hTransfer, data_from_url, 4096, &NumberOfBytesRead) && NumberOfBytesRead )
   {
           cout << data_from_url;
   }

 
system("pause");


CloseHandle(hFileDownload);
InternetCloseHandle(hTransfer);
}
33  Programación / Programación C/C++ / Ayuda con wininet (ftpgetfile y ftpputfile), Detectar porcentaje transferido en: 3 Septiembre 2013, 10:46 am
Hola.
Me gustaria capturar el porcentaje transferido mediante ftpgerfile y ftpputfile.

Se puede?



InternetStatusCallback. Alguien sabe usarlo?
34  Media / Juegos y Consolas / Battlefield 3 victorval, no se ven los menus (SOLUCIONADO) PC en: 13 Agosto 2013, 13:41 pm
Bueno....
Para al que no se les vea los menus... en battlefield 3 a mi me pasa con windows 8, esta es la solucion.

Abren las propiedades del acceso directo del juego y ponen que se ejecute en ventana maximizada y listo....

Espero que os sea de ayuda
35  Programación / Desarrollo Web / Crear efecto radiobutton con checkboxes en js. en: 18 Julio 2013, 21:55 pm
alguien me puede pasar o explicar como conseguir este efecto?
36  Programación / Programación General / Ayuda con este codigo js. Crear style dinamicamente. en: 18 Julio 2013, 10:09 am
Hola. tengo este codigo

Código:
var link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = "@import url(calendario/calendar-blue2.css);";
document.head.appendChild(link);

Sabeis que es lo que falla?
37  Programación / Desarrollo Web / Abrir pagina dentro de div. Ayuda en: 11 Julio 2013, 12:57 pm
Estoy intentando abrir una pagina dentro de un div... Carga la pagina pero pierde la funcion de menu acordeon... ocea, que el menu no se despliega.

Este es el codigo de la pagina que quiero abrir

[avisos1.php]
Código:


<link rel="stylesheet" href="acordeonmenu/css/reset.css" type="text/css" charset="utf-8">
        <link rel="stylesheet" href="acordeonmenu/css/core.css" type="text/css" charset="utf-8">
        <link rel="stylesheet" href="acordeonmenu/css/accordion.core.css" type="text/css" charset="utf-8">
        <link href="acordeonmenu/acordeon.css" rel="stylesheet" type="text/css">
       

<script type="text/javascript" src="acordeonmenu/js/jquery-1.4.2.min.js" charset="utf-8"></script>
<script type="text/javascript" src="acordeonmenu/js/jquery.accordion.2.0.js" charset="utf-8"></script>
<link href="STYLE/horizontalmenu.css" rel="stylesheet" type="text/css" />
           


       <ul id="example2" class="accordion">
                <li>
                    <h3 >Avisos</h3>
                  <div id="asdf" class="panel loading">
                   <p>
<table width="100%" border="1" class="tablaavisos" id="as">
  <tr>
    <td width="26%" height="20">Nombre</td>
    <td width="37%">Apellido</td>
    <td width="18%">D.N.I.</td>
    <td width="19%">Dias</td>
  </tr>
</table>
         
                </p>
                  </div>
                </li>
               
               
  </ul>

<script type="text/javascript">
           
            $('#example2').accordion({
                canToggle: true
            });
           
            $(".loading").removeClass("loading");


        </script>

Y este es el codigo de la pagina que se encarga de abrir avisos1.php mediante ajax

[index.php]
Código:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>



<link rel="stylesheet" href="acordeonmenu/css/reset.css" type="text/css" charset="utf-8">
        <link rel="stylesheet" href="acordeonmenu/css/core.css" type="text/css" charset="utf-8">
        <link rel="stylesheet" href="acordeonmenu/css/accordion.core.css" type="text/css" charset="utf-8">
        <link href="acordeonmenu/acordeon.css" rel="stylesheet" type="text/css">
        <link href="STYLE/tablaavisos.css" rel="stylesheet" type="text/css" />
        <link href="STYLE/botonavisos.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="acordeonmenu/js/jquery-1.4.2.min.js" charset="utf-8"></script>
<script type="text/javascript" src="acordeonmenu/js/jquery.accordion.2.0.js" charset="utf-8"></script>
<link href="STYLE/horizontalmenu.css" rel="stylesheet" type="text/css" />
</head>

<body>

<a href="#" onClick="getID(this)" title="Avisos"><span>Avisos</span></a>
<div id="contenido"></div>
</body>
</html>

<script type="text/javascript">
function getID(theLink){


enviar(theLink.id);

}

function enviar(idform){
// Comprobamos que está disponible AJAX
if(window.XMLHttpRequest) {
ajax = new XMLHttpRequest()
}
// La respuesta aparecerá en una alerta
ajax.onreadystatechange=function(){
if(ajax.readyState == 4) {
if(ajax.status == 200) {
//print(ajax.responseText)
//an.style.display='none';
document.getElementById("contenido").innerHTML=ajax.responseText;

}
}
}
// Pedimos el archivo "prueba.php"
ajax.open("POST","avisos1.php",true)
ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
ajax.send(null)
}
</script>



38  Programación / Desarrollo Web / Ayuda con este codigo. Cargar pagina en div mediante ajax. en: 28 Junio 2013, 16:01 pm
El siguiente codigo muestra la pagina prueba.php en el div asdf.
pero al momento de mostrar la pagina prueba.php, la muestra pero con la misma desaparece.

Código:

echo '<form name="form1" id="form1" method="post" action="#">
      <table width="100%" height="81" border="1">
        <tr>
          <td width="12%">Buscar DNI</td>
          <td width="88%"><input type="text" name="dni" id="dni"></td>
        </tr>
        <tr>
          <td height="40">&nbsp;</td>
          <td><input type="submit" name="BUSCAR" id="ana" onclick="javascript:getIDA(this)" value="BUSCAR";></td>
        </tr>
      </table>
      
    </form>';

?>
 <script src="http://code.jquery.com/jquery-1.9.1.js"></script>


<div id="asdf"></div>

<script type="text/javascript">
function getIDA(theLink){

alert("entro getida");
enviarA(theLink.id);

}

function enviarA(idform){
alert(idform);
// Comprobamos que está disponible AJAX
if(window.XMLHttpRequest) {
ajax = new XMLHttpRequest()
}
// La respuesta aparecerá en una alerta
ajax.onreadystatechange=function(){
if(ajax.readyState == 4) {
if(ajax.status == 200) {
//print(ajax.responseText)
//an.style.display='none';
document.getElementById("asdf").innerHTML=ajax.responseText;

}
}
}
// Pedimos el archivo "prueba.php"
ajax.open("POST","prueba.php",true)
ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
ajax.send("&MM_insert=" + "renovar" + "&dni=" + idform )
}
</script>





SOLUCIONADOˇˇ. Solo tenia que eliminar los formularios
39  Programación / Desarrollo Web / Hechadme una mano con esto. document.forms[0].submit no funciona en: 13 Junio 2013, 23:11 pm
Hola.
Intento crear una tabla dentro de un form al que le pongo el id desde una variable.
y le doy el action y el submit desde un onclick.
Este es el codigo.


Código:
echo '<form id="'.$NOMBRE.'" name="'.$NOMBRE.'" method="post" action="">
  <table width="100%" border="1">
    <tr>
      <td width="26%" height="20"><a href="#" onClick="document.    form1.action[/b]=cargarContenidos(\'cambiarfichaadulto.php\');document. form1.submit();" title="Crear ficha">'.$NOMBRE.'</a></td>
        <td width="37%">'.$APELLIDOS.'</td>
        <td width="18%">'.$DNI.'</td>
         <td width="19%">'.$identificador.'</td>
      </tr>
    </table> <input type="hidden" name="MM_insert" value="renovar" />
                   </form>';

No me funciona de ninguna manera, ni poniendo forms[0], forms['antonio'].
Me podeis ayudar?


document.form1.action asi si funciona, pero quiero manejar los demas forms



40  Programación / Programación C/C++ / Contestar al PING del irc. Ayuda con este codigo en: 22 Mayo 2013, 00:33 am
Hola, no se que es lo que estoy haciendo mal.
este es el codigo que busca el PING y lo contesta, pero me tira ping timeout

Código:
	if (strchr(recvbuf, 'PING') != NULL)
        {
                       //declaro el buffer
char buffer[512];

                  //relleno el buffer asta el char 22 que es el numero de caracteres que lleva el ping ( PING :1234567891234567  )
              for(int i = 0; i < 22; i++){

                       buffer[i] = recvbuf[i];

                   }
                      //LE CAMBIO LA i POR LA O PARA EL PONG
buffer[1] = 'O';



// LO ENVIO PERO AUN ASI ME DA PING TIMEOUT
_iResult = send( ConnectSocket, buffer, strlen(buffer), 0 );
  
Páginas: 1 2 3 [4] 5 6 7 8 9 10 11 12 13
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines