tommyboy123x Posted July 15, 2008 Share Posted July 15, 2008 For some reason when I attempt to connect to the server to download the log file (it has get variables to specify the date range), it won't work Also, this code is extremely... "simplified" and yet so ugly $url = 'http://..../'; #an example URL $password = 'password'; $username = 'username'; filename = 'filename'; $file = 'csvuploads/'.$filename; $timestamp = time(); $em = date('n', $timestamp); #end month $ed = date('j', $timestamp); #end day $ey = date('Y', $timestamp); #end year $timestamp2 = $timestamp - 150000; $sm = date('n', $timestamp2); #etc... $sd = date('j', $timestamp2); $sy = date('Y', $timestamp2); $url0 = str_replace('{ey}',$ey,$url); $url1 = str_replace('{sm}',$sm,$url0); $url2 = str_replace('{sd}',$sd,$url1); $url3 = str_replace('{sy}',$sy,$url2); $url4 = str_replace('{em}',$em,$url3); $url = str_replace('{ed}',$ed,$url4); $ch = curl_init(); $handle = fopen($file, 'w+'); echo 'em: '.$em.'<br />ed: '.$ed.'<br />ey: '.$ey.'<br />sm: '.$sm.'<br />sd: '.$sd.'<br />sy: '.$sy.'<br />url: '.$url.'<br />username: '.$row['username'].'<br />password: '.$row['password'].'<br />'; curl_setopt($ch, CURLOPT_COOKIEJAR, "inc/cookies.txt"); curl_setopt($ch, CURLOPT_COOKIEFILE, "inc/cookies.txt"); //curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_USERPWD, $username.':'.$password); curl_setopt($ch, CURLOPT_FILE, $handle); if (!curl_exec($ch)){ echo 'An error has occured!<br />Code: 8523x8'; exit(); } curl_close($ch); It creates the file and can output the data, however it gets hung up on the curl_exec(), where it doesn't connect properly. It loads for about 30 seconds and then gives up. Any advice? Also, I've tried copy() with even less luck using https://username:password@domain.com/....etc.../. Help appreciated! Quote Link to comment Share on other sites More sharing options...
tommyboy123x Posted July 15, 2008 Author Share Posted July 15, 2008 bump? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.