Author |
Message |
sven2157
Hangin' Around
Joined: Jun 13, 2009
Posts: 40
Location: Chicago, IL
|
Posted:
Sun Jan 17, 2010 10:41 am |
|
Hello Everyone
First, I hope this post is in the right place. If not I am sorry. I am desperately trying to learn php "on the fly". I have been searching the internet for the last 4 days on this issue.
Secondly, I am NOT looking for someone to write this script for me. As the title says, I WANT to learn how to do this myself.
So, here goes...
Let me start with my basic information:
1. - Windows IIS 7 @ GoDaddy <-- This will not change! So if your ONLY suggestion is, "find a real hosting company", do us all a favor and please move on and do not reply.
2. - PHP 5.2.5 w/ MySQL 5
3. - allow_url_fopen = On
4. - allow_url_include = Off
5. - Directories on the Development are ALL 777 (Read/Write in IIS).
What I am trying to accomplish, I think is simple: I have a Call of Duty 4 Server and FTP site through GameServers.com. I have downloaded and installed Ultrstats 3.16. Everything works great accept when I try to download the games_mp.log from the Game FTP via the admin panel in Ultrastats. I get "could not connect to FTP as User, blah, blah, blah. However, if I copy the URL from the FTP builder in Ultrastats, and paste it into IE/FF's address bar, I automatically and instantly start downloading the .LOG file from my game [ Only registered users can see links on this board! Get registered or login! ]
Example: ftp://<username>:<password>@8.12.23.50:21/<userdir>/cod4/Mods/awe4/games_mp.log
I have read numerous posts on this, and either the post went dead, or the problem was solved, but the poster never said how they solved their problem. You've seen it too, "I fixed it! Thanks for the help!", and that is it! GRRRR... That is so aggrevating!
The forums for Ultrastats are in German and broken English, for support, so I thought (probably where I originally went wrong; thinking! ), "If I could write a simple PHP script to open the FTP connection, retrieve the .LOG and save it to my web server, I could CRON the parsing of the file. Just bypass the built in FTP, in Ultrastats all together.
This is proving more troublesome than I thought. When I follow the PHP manual for $ftp_connect():
Code:<?php
$ftp_server = "8.12.23.50";
// set up a connection or die
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
?>
|
I get a "500 - Internal server error". So I figured that maybe the server is trying to authenticate the login credentials. So I kept looking and found $ftp_login. If I try to incorporate the $ftp_login:
Code:<?php
$ftp_server = "8.12.23.50";
$ftp_user = "<username>";
$ftp_pass = "<password>";
// set up a connection or die
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
echo "Connected as $ftp_user@$ftp_server\n";
} else {
echo "Couldn't connect as $ftp_user\n";
}
// close the connection
ftp_close($conn_id);
?>
|
Still get the "500 - Internal server error". So I tried to alter the code a bit. This time trying to use the URL that I can paste into IE/FF and have it connect:
Code:<?php
// set up basic connection
$ftp_server = "ftp://8.12.23.50/<userdir>/cod4/Mods/awe4/games_mp.log";
$conn_id = ftp_connect($ftp_server);
// check connection
if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!";
exit;
} else {
echo "Connected to $ftp_server, for user $ftp_user_name";
}
?>
|
This time I get,
"Warning: ftp_connect() [function.ftp-connect]: php_network_getaddresses: getaddrinfo failed: No such host is known. in <absolute useraccount path>\html\websites\dev.170thclan.com\Ultrastats\gamelogs\getlog.php on line 4
FTP connection has failed!"
So I thought the credentials were stopping me again and tried:
Code:<?php
// set up basic connection
$ftp_server = "ftp://8.12.23.50/<userdir>/cod4/Mods/awe4/games_mp.log";
$ftp_username = "<username>";
$ftp_password = "<password>";
// set up a connection or die
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
echo "Connected as $ftp_user@$ftp_server\n";
} else {
echo "Couldn't connect as $ftp_user\n";
}
?>
|
When I do this, I get
"Warning: ftp_connect() [function.ftp-connect]: php_network_getaddresses: getaddrinfo failed: No such host is known. in <absolute useraccount path>\html\websites\dev.170thclan.com\Ultrastats\gamelogs\getlog.php on line 8
Couldn't connect to [ Only registered users can see links on this board! Get registered or login! ]".
I have even tried to make the connection passive, "ftp_pasv($conn_id, true);" , but that doesn't seem to make a difference either. I can see that the connection is where it is failing, but I do not know why! As I don't have acces to the 500 logs, I can't go from there either...
What am I missing/doing wrong? Any help would b most appreciated.
Thanks,
Sven2157 |
|
|
|
|
spasticdonkey
RavenNuke(tm) Development Team
Joined: Dec 02, 2006
Posts: 1693
Location: Texas, USA
|
Posted:
Sun Jan 17, 2010 11:39 am |
|
At one time I was trying to get the donations block working on godaddy and ran into issues with it's use of fopen
This was several years ago, but I remember some suggestions of using cURL.
But this is the point where I changed hosting companies, and I have no familiarity with cURL; so maybe at least it gives you another direction to try.. |
|
|
|
|
sven2157
|
Posted:
Sun Jan 17, 2010 11:46 am |
|
spasticdonkey wrote: | At one time I was trying to get the donations block working on godaddy and ran into issues with it's use of fopen
This was several years ago, but I remember some suggestions of using cURL.
But this is the point where I changed hosting companies, and I have no familiarity with cURL; so maybe at least it gives you another direction to try.. |
Thanks for the reply! I have the donations block on the "Live" site and it works great: 170th Clan. It is on the right side towards the bottom. I have allow_url_fopen = On in my php5.ini. So the fopen is not stopping me...
I am not familair with cURL at all, either. I just don't get why it doesn't connect to the FTP server?
If there is a better way, I am all open to suggestions. Basically need to download the Game Log to the correct directory; server to server...???? I would think that would be simple enough??? |
|
|
|
|
Palbin
Site Admin
Joined: Mar 30, 2006
Posts: 2583
Location: Pittsburgh, Pennsylvania
|
Posted:
Sun Jan 17, 2010 12:13 pm |
|
[ Only registered users can see links on this board! Get registered or login! ]
Quote: |
The FTP server address. This parameter shouldn't have any trailing slashes and shouldn't be prefixed with [ Only registered users can see links on this board! Get registered or login! ]
|
Let me know how that goes for you |
_________________ "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan. |
|
|
|
sven2157
|
Posted:
Sun Jan 17, 2010 12:19 pm |
|
sven2157 wrote: | This is proving more troublesome than I thought. When I follow the PHP manual for $ftp_connect():
Code:<?php
$ftp_server = "8.12.23.50";
// set up a connection or die
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
?>
|
I get a "500 - Internal server error". So I figured that maybe the server is trying to authenticate the login credentials. So I kept looking and found $ftp_login. If I try to incorporate the $ftp_login:
Code:<?php
$ftp_server = "8.12.23.50";
$ftp_user = "<username>";
$ftp_pass = "<password>";
// set up a connection or die
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
// try to login
if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
echo "Connected as $ftp_user@$ftp_server\n";
} else {
echo "Couldn't connect as $ftp_user\n";
}
// close the connection
ftp_close($conn_id);
?>
|
Still get the "500 - Internal server error". |
Like that |
|
|
|
|
Palbin
|
Posted:
Sun Jan 17, 2010 12:46 pm |
|
I saw these Code:$ftp_server = "ftp://8.12.23.50/<userdir>/cod4/Mods/awe4/games_mp.log";
|
I'm flying blind here just throwing out suggestions because I have never done anything like this. |
|
|
|
|
Palbin
|
Posted:
Sun Jan 17, 2010 1:11 pm |
|
This worked 100% for me. So I would ask godaddy about the 500 server error.
Code:
<?php
$ftp_server = 'xx.xxx.xx.xxx';
// set up a connection or die
$conn_id = ftp_connect($ftp_server);
if ($conn_id) {
echo 'success';
} else {
echo 'Couldn\'t connect to ' . $ftp_server;
}
ftp_close($conn_id);
$ftp_server = "xx.xxx.xx.xxx";
$ftp_user = "xxxxxx";
$ftp_pass = "xxxxxx";
// set up a connection or die
$conn_id = ftp_connect($ftp_server);
if ($conn_id) {
echo 'success';
} else {
echo 'Couldn\'t connect to ' . $ftp_server;
}
// try to login
if (ftp_login($conn_id, $ftp_user, $ftp_pass)) {
echo 'Connected as ' . $ftp_user . '@' . $ftp_server . "\n";
} else {
echo 'Couldn\'t connect as ' . $ftp_user . "\n";
}
// close the connection
ftp_close($conn_id);
?>
|
You should expect an warning like the following if you connect, but do not authenticate properly.
Warning: ftp_login() [function.ftp-login]: Login authentication failed in ................... |
|
|
|
|
sven2157
|
Posted:
Sun Jan 17, 2010 1:23 pm |
|
Thanks Palbin, I will try this now...
Sorry, I have my email set to receive notifications, but it is apparently slow...
Sven2157
*** EDIT ***
The 500 error still... I have just contacted GoDummy about the logs. I will post back when I hear from them...
In the meantime, thank you for your help thus far!
Sven2157 |
|
|
|
|
Raven
Site Admin/Owner
Joined: Aug 27, 2002
Posts: 17088
|
Posted:
Sun Jan 17, 2010 10:21 pm |
|
Have you tried removing the <> from your inputs?
$ftp_server = "8.12.23.50";
$ftp_user = "<username>";
$ftp_pass = "<password>";
TO
$ftp_server = "8.12.23.50";
$ftp_user = "username";
$ftp_pass = "password"; |
|
|
|
|
sven2157
|
Posted:
Sun Jan 17, 2010 10:47 pm |
|
Raven wrote: | Have you tried removing the <> from your inputs?
$ftp_server = "8.12.23.50";
$ftp_user = "<username>";
$ftp_pass = "<password>";
TO
$ftp_server = "8.12.23.50";
$ftp_user = "username";
$ftp_pass = "password"; |
Thank you for the reply Raven! I have to admit I am a bit honored that you had the time to reply! But, I have to laugh alittle. I just used the <username> to mark place holders, for my actual username and password. To answer your question, though, yes I did it without the '<''>' carrats.
I have GoDaddy trying to fix the issue as I type. Their own coders are having a problem, too. So there is something definately wrong with either, my particular setup, or the machine itself. I would have to say the machine, as I have been experienceing other non-scripting/programming issues. I think my server is dieing!
Makes it REALLY hard to learn something, when I may have done it right several times, over the last 4 days, before asking for assistance!
Since I have your attention, I would like to say that you have a great group of very knowledgable and helpful people here! I can't wait to start contributing to others, instead of needing others contributing to me! Thank you for your devout generousity and providing an excellent reference/resource to the community, both at home and abroad!
Thanks again for the reply, and I will post back as soon as I hear back from GoDaddy.
Sven2157 |
|
|
|
|
Raven
|
Posted:
Mon Jan 18, 2010 3:02 am |
|
NP. Yes, the RN Team and outside contributors are some of the top experts in the Community. I am honored that they have chosen to work with this site and this Team. Just as a plug (no shame at all) be sure to consider Raven Web Hosting LLC. It is a very solid hosting environment and is setup for developers as well as novices. In other words you won't find limits for things that you need to get your job done
See some recent reviews at [ Only registered users can see links on this board! Get registered or login! ] |
|
|
|
|
sven2157
|
Posted:
Wed Feb 17, 2010 2:06 am |
|
I am back to report, sorry it took so long, that I haven't made any progress with GoDaddy on this.
I wrote a custom php5.ini file and still have not had any luck. I don't understand what it is I am doing wrong. If they say that it is my script, and that I should seek "professional php developer's opinoins", I do, and they say it is my code...
Where does that leave me?
If anyone has any suggestions for this type of action, I would love to know...
So I will re-ask my question:
I want a script that will go to my gaming server, retrieve a game.log and save it on my webserver.
What would be the best way to do this?
Thanks again guys.... |
|
|
|
|
wHiTeHaT
Life Cycles Becoming CPU Cycles
Joined: Jul 18, 2004
Posts: 579
|
Posted:
Wed Feb 17, 2010 4:30 am |
|
ther seems to be issue's with godaddy for ftp abouth port 21 |
|
|
|
|
wHiTeHaT
|
Posted:
Wed Feb 17, 2010 5:25 am |
|
i find for you a code snippit you might want to try out:
Code:
<?php
//This is usefull when you are downloading big files, as it
//will prevent time out of the script :
set_time_limit(0);
ini_set('display_errors',true);//Just in case we get some errors, let us know....
$fp = fopen (dirname(__FILE__) . '/games_mp.log', 'w+');//This is the file where we save the information
$ch = curl_init('http://uffclan.net/fightingmedic/cod4/mods/awe4/games_mp.log');//Here is the file we are downloading
curl_setopt($ch, CURLOPT_TIMEOUT, 50);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_exec($ch);
curl_close($ch);
fclose($fp);
?>
|
Tested on godaddy server and works perfectly |
|
|
|
|
wHiTeHaT
|
Posted:
Wed Feb 17, 2010 6:05 am |
|
this should do the trick for ftp couse you use ftp protocal to acces:
Code:
$curl = curl_init();
$file = fopen("ls-lR.gz");
curl_setopt($curl, CURLOPT_URL, "ftp://ftp.sunet.se/ls-lR.gz"); #input
curl_setopt($curl, CURLOPT_FILE, $file); #output
curl_setopt($curl, CURLOPT_USERPWD, "$_FTP[username]:$_FTP[password]");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_exec($curl);
|
|
|
|
|
|
sven2157
|
Posted:
Wed Feb 17, 2010 8:46 pm |
|
wHiTeHaT wrote: | i find for you a code snippit you might want to try out:
Code:
<?php
//This is usefull when you are downloading big files, as it
//will prevent time out of the script :
set_time_limit(0);
ini_set('display_errors',true);//Just in case we get some errors, let us know....
$fp = fopen (dirname(__FILE__) . '/games_mp.log', 'w+');//This is the file where we save the information
$ch = curl_init('http://uffclan.net/fightingmedic/cod4/mods/awe4/games_mp.log');//Here is the file we are downloading
curl_setopt($ch, CURLOPT_TIMEOUT, 50);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_exec($ch);
curl_close($ch);
fclose($fp);
?>
|
Tested on godaddy server and works perfectly |
This did work perfectly! Thank you!
I am not familiar with cURL though... so I guess that GoDaddy is not the best place to learn some of these php functions...
Perhaps, I will study up a bit on cURL!
Thanks again! |
|
|
|
|
|