Reply to Help please

Your name:

Reply:


Posted by Freebird on 09/29/42 11:31

Hello you guys,

I've with a problem, I hope you guys can help me.

I need, from server b, to connect to server a, over the internet, to be able
to open a .txt file and make it a copy to insert line by line inside server
b, the problem, is that I need to make sure the user from server b, is
someone ok, what I mean is, there's a table inside server a, and the user
from server b, to be able to open the file, must be in that table in server
a, to be able to login, but I'm not sure how to connect to server a from
server b, make a verification in the database from server a, and allow the
user to open the file, copy it, and insert into server b database.

So far I can from server b, open the file in server a, copy it, and insert
line by line in server's b database, here's the, I hope you guys can help
me:


/*******************************************
* Function cached_fopen_url():
* Caches data from a HTTP resource/url to a
* local file (HTTP headers are stripped)
*******************************************/
function cached_fopen_url($url, $file_mode, $timeout_seconds = 90,
$cache_path, $fsocket_timeout = 10, $name_db, $host_db, $user_db, $pass_db){
$debug = FALSE;
clearstatcache();
//$cache_filename=$cache_path . "/" . urlencode($url) .".cached";
$cache_filename= $cache_path."proxylist.txt";

if($debug){
print "local_cache creation_time =" .
@filemtime($cache_filename) .
" actual time = " . time() .
" timeout = " .
timeout_seconds ."<p>";
}

//if ( ( @file_exists($cache_filename ) and ( (
@filemtime($cache_filename) + $timeout_seconds) > ( time() ) ) ) ) {
if ( ( @filemtime($cache_filename) + $timeout_seconds) > ( time() ) ) {
// ok, file is already cached and young enouth
if ($debug) { print "using cached file ($cache_filename) <p>";}
} else {

if ($debug) {
print "caching file ($url) to local ($cache_filename)<p>";
}

$urlParts = parse_url($url);
$host = $urlParts['host'];
$port = (isset($urlParts['port'])) ? $urlParts['port'] : 80;

if( !$fp = @fsockopen( $host, $port, $errno, $errstr,
$fsocket_timeout )) {

// Server not responding
} else {

if( !fputs( $fp, "GET $url HTTP/1.0\r\nHost:$host\r\n\r\n" ) ) {
die( "unable to send get request" );
}

$data = null;
stream_set_timeout($fp, $fsocket_timeout);
$status = socket_get_status($fp);
while( !feof($fp) && !$status['timed_out']){
$data .= fgets ($fp,8192);
$status = socket_get_status($fp);
}
fclose ($fp);

// strip headers
$sData = split("\r\n\r\n", $data, 2);
$data = $sData[1];

// save to cache file
$f2 = fopen($cache_filename,"w+");
fwrite($f2,$data);
fclose($f2);
}
}

// ok, point to (fresh) cached file
if ( @file_exists($cache_filename )) {
$handle = fopen($cache_filename, $file_mode);
$data = array();
for($x = 0; !feof($handle); $x++ ){
$data[$x] .= fgets ($handle,8192);
}
if( count($data) > 0 ){
//truncate table for new
$this->_mysql_multi_query($data, $name_db, $host_db, $user_db,
$pass_db);
}
}
return TRUE;
}
}


Tks a lot


Freebird

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация