Can't Read Remote Web Page From Local Apache/PHP
I'm trying to read the contents of any Web page on another
host. I'm finding that...
echo file_get_contents( 'http://www.php.net' );
.... works fine if I upload the PHP script to my Web host, and run it
there. But if I run it on my PC, which is running Apache 1.3.33
(Win32) and PHP 5.0.5, then it always times out, and gives me the error
message...
[error] PHP Warning: file_get_contents(http://www.php.net) [<a
href='function.file-get-contents'>function.file-get-contents</a>]:
failed to open stream: A connection attempt failed because the
connected party did not properly respond after a period of time, or
established connection failed because connected host has failed to
respond.
I get the exact same results using...
$fh = fopen( 'http://www.php.net', 'r' ) or die( $php_errormsg );
while (! feof($fh)) {
$page .= fread($fh,1048576);
}
fclose($fh);
echo $page;
Anyone know what could cause this to happen?
View Complete Forum Thread with Replies
Related Forum Messages:
Connect Page (local) To Remote Database:
I'have Easy PHP in localhost and i need connect php page (local) to remote database: $db_host = "62.149.225.23"; $db_user = "gfo"; $db_password = "gfo"; $db_name = "gfonline"; $db = mysql_connect($db_host, $db_user, $db_password); The browser show this message: Warning: mysql_connect(): Can't connect to MySQL server on ེ.149.225.23' (10061) in e:phpgfonline.itprovaremoto.php on line 7
View Replies !
Remote To Local DB Sync
help me with regards to an efficient way in which to synchronize a localhost MySQL DB with a remote MySQL DB? I cannot use any 3rd party software as my host does not allow external access to the remote DB.
View Replies !
Printing To Local Machine For The A Remote Site
I would like to find out if I can get a page to print on a printer physically next to the server when a user of my site clicks the submit button. I'm sure that there's a way, but being new and slightly slow I'm not sure where to even begin looking.
View Replies !
Download Files From Remote Server To Local Webserver
I am trying to create a php page whereby people can download files from a remote server to their own server (to update their webdirectory with updated files/images etc). So for example one php page (e.g. update.php) should be able to download files from a remote server to a specific directory on their local webserver. Is this possible?
View Replies !
Date Function On Local Server To Remote Host
This little combo was giving me Sunday, April 30 on my local server and Thursday, April 1 on my remote host, and I can't for the life of me figure out why. I could swear it used to work. PHP Code: $today = gmmktime(0,0,0,date('m,d,Y',gmmktime())); echo gmdate('l, F j', $today); (The first function gives me a "midnight" time stamp, so all dates put into the db, and compared to it, are consistent). When I rewrote it thus, it worked fine on both hosts: PHP Code: $m = date('m',gmmktime()); $d = date('d',gmmktime()); $y = date('Y',gmmktime()); $today = gmmktime(0,0,0,$m,$d,$y); Any idea what the heck is going on?
View Replies !
How To Process A Local File Rather Than Just Read It
I can read a local file with fopen("myFile.php"); However this gives me the source of the file (i.e. php code). I want to get the results of the file after it has been evaluated (i.e. HTML). The obvious way of doing this is include 'myfile.php' However, I want to process the evaluated result. For example: echo htmlentities( include 'myfile.php' ); This doesn't work because the result of the include statement is true or false rather than a string. I'm sure this is very simple, but I'm just learning.
View Replies !
Copying File From Hosted Remote Sever To Local Machine
I am trying to use php to automate the copying of a file from my remotely hosted directory to my computer. I have put together the following but it will only do the copying from one directory to another on the remote server. Reading the postings on these functions they suggest that it can be done but it appears to be the case if your are hosting your site on the same machine you want to copy the files to. Does anyone know if there are functions in php to do the transfer from remote server to my machine or if the code below will acheive this with modification? <?php $ftp_server = "xxxxxxxx"; $ftp_user = "xxxxxxx"; $ftp_pass = "xxxxxx"; $local_file = 'myfile.txt' $server_file = 'myfile.txt' // set up a connection or die $conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server"); $login_result = ftp_login($conn_id, $ftp_user, $ftp_pass); // check connection if ((!$conn_id) || (!$login_result)) { die("FTP connection has failed !"); } // try to change the directory to myfilesdirectory if (ftp_chdir($conn_id, "myfilesdirectory")) { echo "Current directory is now: " . ftp_pwd($conn_id) . ""; } else { echo "Couldn't change directory"; } if (ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)) { echo "Successfully written to $local_file"; } else { echo "There was a problem"; } // close the connection ftp_close($conn_id);
View Replies !
Local Apache Web Server
At the moment I am using "easyphp" on my computer to test my php code. However, I would like to get a little more advanced and replicate an apache server on my home computer. Such that I can build a website using .htaccess on my home computer. I can build it at home, then upload it all nice and finished to an apache server. Does anyone know where I can get an apache server for my home computer? A kind of local host for apache? Also, I would like an IMAP email client on my server and to have some PHP code that is able to "read"/parse my incoming emails. Open them up - "read" them by looking for keywords - then delete them etc. Code:
View Replies !
Local Apache Server
My php script uploads my files fine. I did a chmod 777 to the directory I want uploaded files to go, but when I upload to that directory (with php) none of the files have permissions, but the files are there. What's going on.
View Replies !
Local Apache Web Server Revisited
I would like to replicate an apache server on my home computer. Conclusions of a previous thread on this topic: 1) Use the same operating system for your local apache server as your host uses. Any comments on just how important this is would be very welcome because i am thinking of cutting a corner and running my local apache server on windows XP. My prospective host uses Linux. 2) There are some nice "neat, easy, tidy" installs of apache (with PHP and MySQL) available. easyphp AppServ XAMPP Any comments on which one is best would be highly appreciated. As would further suggestions. 3) Things that I want to do which are a bit special: ) Use the PHP IMAP functions. These are a PHP extension. http://uk2.php.net/imap So, I will have to add this extension. How easy is this with these local apache servers? ) Does anyone know an IMAP email client that I can put on my local host apache server? courier-imap or CyrusIMAPD are apparantly possibilities. Can anyone point me to any reseources that would guide me through setting up these clients so that they are integrated with the apache web server - so that PHP code on the apache server could have access to emails in the IMAP email inbox. PHP code on the server can send emails from the IMAP email inbox.
View Replies !
Apache Local Test Server On XP Pro
I'm hoping someone can help me with the following. My son is learning PHP and wants to install an apache test server on our XP pro home computer so he can test his code before uploading it to his hosting company. I don't have a problem with this in principle but I do have the following concerns: 1) We connect to the internet via AOL and my son's account is a "young person access" account. Will this be compromised by apache? 2) Will the installation of this apache server allow my son to breach Windows security at all (he is a restricted user at present)? 3) Any other possible security issues?
View Replies !
Php Function To Read Local Python Script Output, Not Code
On my server python has to run in the wwwroot/cgi-bin folder, but php can run anywhere. My site is going to be written in python but I don’t want my user to see the url as mysite/cgi-bin/... . So for example my homepage, index.php should contain a simple php script that will get my python page from the cgi-bin directory and display it. However when I try to use SSI or fopen/file_get_contents/readlink and commands like these it just displays the python code. Where as when I visit the python page in my browser it runs it and displays the output for me. My question is what php function can I use to execute my python page and return the output, not the code itself. (I think my hosting provider has disallowed certain powerful commands like system() etc. Does this make it impossible?). As the very least can’t my php script pretend to be a www user and ‘visit’ the python page to read the output?
View Replies !
Local Apache Server Error, But Ok When Hosted
I have just used a script that includes the first line session_start(); On my computer where I have apache php and mysql installed I get the error: Warning: session_start(): open(/tmpsess_4e8a9cf51a21ab1c9fe26630d5446262, O_RDWR) failed: No such file or directory (2) in c:serverapachehtdocsmaindex.php on line 2 But when I upload it to my host the page works without errors. Is there a problem with my apache setup or is it a php thing?
View Replies !
Time Different Between My Apache Server And My Local Clock
I actually have two questions: 1. I try to get current time, but the time I got is 1 hour different from my local time. I assume it is caused by Time Zone. So is there any easy way to fix this? I assume that I can first get the Time Zone of the server by using the T option in date, and then using my local Time Zone to calculate the difference. But I am wondering if there is some buil-in function to do it. 2. I found out this also today while workng on the same project. My apache clock is 10 mins slower than my local clock. Any suggection to calibrate the apache server clock (I don't own the server)?
View Replies !
Problems Uploading Files Using Apache And Php On A Local Windows PC.
I've got some problems uploading files using apache and php on a local Windows PC. I'm using the file upload example from the manual, but i can't get it to work. I don't get an error message, it's asif nothing happens. I can't find the file that should be uploaded on my harddisk. Has anyone a working example for file-uploads on a local server with the settings for the php.ini file? Any tips?
View Replies !
Open/read A Remote Https File?
How can I do this? cURL isn't available. I have tried Code: $filename = "https://friends.domain.com/file.aspx; $handle = fopen($filename, "r"); But $handle doesn't seems to exists Any suggestions??
View Replies !
Read And Print The Contents A Text File Which Resides In A Remote Location Via PHP?
Is it possible to read and print the contents a text file which resides in a remote location via PHP? For instance, this is how I am currently reading a text file that is my local server (and it works great, but unfortunately the text file my client will need to have read is outputted to a remote location): <?php $currentSong = "/home/medusa/sun/accounts/username/public_html/ticker/current-song.txt"; $fh = fopen($currentSong, 'r'); $theData = fread($fh, filesize($currentSong)); fclose($fh); echo "<p>".$theData."</p>"; ?>
View Replies !
Read The Username That They Logged In With Through Apache?
I am using my webhost's username and password system, which generates .htaccess and .htpasswd user verification (Bluehost). I want users to login to the password protected subdirectory (let's say www.example.com/clients/) with the browser's default login dialog box, which is all automated by Apache and the web browser... But once they are logged in, I want the target page (www.example.com/clients/index.php) to read the username that they logged in with and redirect them to a subdirectory with that name (www.example.com/clients/username/). Is there a way for PHP to read the username that they logged in with through Apache? Perhaps some kind of HTTP request that will return the username as a variable?
View Replies !
Sql Query Or Apache File Read?
I'm optimizing my script because my server is under heavy load in the evening. I have a question which methode is more efficient for my server: ================== //connection with database is already open because other queries where executed first. $sql="select * from category where siteid=?" // category table contains about 1000 records, only 10 are returned //loop with php code through resultset and print the name and id's of category ================== or ================== <script src="cat.js"></script> cat.js contains javascript document.write() instruction to write 10 categories. ================== In simple words: which is more efficient, a sql query with php or a file read done by apache?
View Replies !
Php.ini Is Not Refreshing/being Read When Apache Is Restart
I am running php 4.3.4 Win 32 as a module with Apache 1.3.29. I am trying show this modification in the php.ini file session.save_path = C:PHPphpsessiondata But when I restart then then go into PEAR to begin an install I allways have the following errors at the bottom of the page. Warning: Unknown(): open(/tmpsess_3476e5826cc724d730b79148be0386ab, O_RDWR) failed: No such file or directory (2) in Unknown on line 0 Warning: Unknown(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0
View Replies !
Php MySQL Works On Remote Server, Only Partially On Local Server
code to populate form select fields with data from a MySQL database, so a user can use those to sort/filter and view the 3,000 records. No inserts -- just selects; very simple. I originally set this up using URL-based query strings at http://stjuliana.org/school/ar/BUindex.php but since that only allowed sorting and not filtering, hence all 3k records load, I made a form verson at http://stjuliana.org/school/ar/index.php . Everything works just fine, however, there's still a lot of tweaking I want to do, such as splitting the form input and output into two pages (_blank), having a printable version, etc. To that end I just set up the latest builds of Apache, php and MySQL on my local Windows XP box, lest I blow my beer budget for the month on bandwidth overage. <g> I have a very simple page I used to test my localhost setup and everything's fine. I can connect to MySQL, create, insert and select from DBs, so I know my config is fine. All my other .php pages on this site work fine locally as well. The two abovementioned pages, however, are giving me fits when run locally... For the URL-query-string version, it loads up with the default view (=name_ns), which grabs all records and sorts by name and point asc. No matter which of the other sort 'views' I might choose, it still loads up all the records in that default sort. The server's holding on to something and I don't know how to clear it. The remote version correctly sorts based on the query string chosen. The form version is worse. It connects to the DB and populates the select boxes with the field data -- that part's fine. But no matter which submit button is selected, no data is retrieved. I get no error, but no data either. The form's action is set to $_SERVER['PHP_SELF'] and I've tried both GET and POST -- no change. Since the exact same pages work on the remote server I know it has to be something on the local setup. But where do I look if there's no obvious error? This is probably something incredibly basic but I'm bleary-eyed from reading tutorials and forums all over the Internet and can't come up with anything.
View Replies !
Can't Read Form Variables After Reinstalling Apache
I reinstalled Apache (2.0.52) and added the appropriate lines to run php scripts to the bottom of the httpd.conf file. The scripts run fine (for example, 'print "Hello!"' yields "Hello!" rather than displaying all of the code (which would occur if the php script wasn't being processed by php.exe first). However, variables passed from a form are read as null/empty. Any idea why, and/or how I can fix this? I found it hard to believe that there would ever be a configuration setting for that kind of thing (since it's the 'meat and potatoes' of server-side web scripting), but I looked through the httpd.conf file extensively nonetheless and could find nothing that looked like it could be set to adjust for this. I'm having the same problem now when I install it on my Linux system as well.
View Replies !
Pass The Variable From 1st Page And Read It With Other Name On 2nd Page
I am new to this and learning slowly, but I was hoping someone could give me some quick advice on how to create a variable on one page and have it passed to another to be read as an ID for a mySQL database. I want to pass the variable "varRevID" from one page and have it read as "reviews_id" on the other. My database is pulling from just the first record and I would liek to designate from the pointing page which record to pull from.
View Replies !
Link To Local Files Through A Dynamic Page
I decided to flesh out my php skills by building a web application which could scan through local files on my intranet (specifically mapped drives on my server) and generate a list of Movies or pictures or music, etc. Which worked fine, I created the code to do that and to store the results in a mysql database. I can even print it out to a ..php page and sort it however I like. What I can't seem to do is to create links to the data I've indexed in a way that will let me open them from the generated php page. I've searched and searched and there just doesn't seem a way to do this. I'm pretty sure I've exhausted the obvious options. The following trials did not work when the document was served from an apache web server. <?php echo "<h1><a href=file:///c:/temp.txt> HEY </a></h1>"; echo "<h1><a href=file:///c: emp.txt> HEY </a></h1>"; ?> <a href=file:///c: emp.txt target="_top"> temp.txt </a> <a href=file:///c:/temp.txt target="_top"> temp.txt </a> When the same page was loaded directly from the file instead of served through apache the bottom two links worked. This doesn't really help me however. I need to be able to dynamicly generate pages that link to the files. I've read that browser security is the restricting factor in this but changing all of my security settings in IE to low didn't seem to affect it (not sure what the equivalent of security settings is in Firefox). Does anyone know of a way to link to local files directly in a way that lets you open them directly from the source instead of by downloading them to a temp file or saving the file to somewhere locally? Is it even possible in PHP?
View Replies !
How To Print The Local Variables Used In A Generated Page
I am still a beginner of PHP, and while I found out the way to print all the variables passed as a POST, I was wondering (for debugging purposes) if there is a simple way to tell the PHP interpreter to print out all the variables that have been used during that session, without storing anything anywhere, and without buying a commercial tool.
View Replies !
Hyperlink From Intranet Web Page To Local Files On My Computer
I'm creating a company intranet, and every employee has certain program we want them to be able to run from it, meaning we want the link to the program to be on the intranet page. For example, Adobe Photoshop resides on all the employees computer under "C:Program FilesAdobePhotoshop 7.0Photoshop.exe" However, when I enter that as a hyperlink on the page, it does not run the program. Is there a way to get a web page to run a program on the local host?
View Replies !
Remote Page
i am having a some difficulty with the following code; PHP Code: $file = fopen ("$url", "r"); if (!$file) { echo "<p>Unable to open remote file. "; exit; } while (!feof ($file)) { $line = fgets ($file, 1024); /* This only works if the title and its tags are on one line */ if (eregi ("<TITLE>(.*)</TITLE>", $line, $out)) { $title = $out[1]; break; } } fclose($file); It is doing its job perfectly on one seve I have but on a new host I have it seems to be causing the page it is reading, to be opened and executed over and over again. Can anyone here think of a fix that will allow it to just read the file once without executing the file. Basically this is reading the title tags of a page, and feeding this into a counter that requires the page title (this is what $title is). $url is grabbed from the current page that has been opened up in the browser. And from there - is supposed to be read (not executed). where the title can be grabbed, and passed to the counter.
View Replies !
Remote Web Page Information
I am trying to create a script that can grab information from a 3rd party website. For example, say I wanted to copy the text "Advertising Programs - Business Solutions - About Google" Off of Google's homepage. I wanted my website to open Google and select that text and output it onto my site. So if Google where to edit that information, it would also edit on my site. Anyone have any idea how to do this? I had a buddy who did that once with a Roster Rankings chart for IGN Gamespy Arena, but he ran off.
View Replies !
Fetch Remote Page
i have the following code that fetches a remote webpage: $open = fopen("http://www.example.com/page.htm", "r"); $read = fread($open, 9024); fclose($open); echo $read; while fetching the remote webpage i want my code to tell the remote webpage that my user agent is NSPlayer/9.0.0.2980 WMFSDK/9.0 otherwise the webpage does not display the relevant information i need. how i can do this?
View Replies !
Parse A Remote Web Page
I would like to display some information from a remote web page on my own website. The tags I am looking for are <a name="picture" href="pictures" title="variable1"><img alt="variable1" title="variable1" src="mysite.com/myimage.jpg" border="0" height="140" width="98"></a> I need to get the <img tag. I don't need the <a part.
View Replies !
Remote/outside Page Data
I am asking probably has a simple answer. i want to be able to grab the source code from an outside URL, so i can deal with it in my page. an example of this would be sending an XML feed request via a specific URL, and getting a page of XML in return- then dealing with the returned XML information on my own. how do i send the request, and how do I read the returned information.
View Replies !
Detect Change Of Remote Page
i have some links on my site, i need to be absolutely sure that the html has not been modified, even one character. i would rather not rely on http headers, just the html (so it is not dependant on the webserver). should i make a database to actually mirror the page, and then check against my copy? any better ideas? :)
View Replies !
Open And Process Remote Page
I want to be able to ask users for a URL, open that page, change some of the contents and then display that page as if they had typed the URL into a browser. I have toyed with some of the php functions for opening URLs, but what I am not clear on is how much work my script will have to do (do I need to fully emulate a browser, for example). The net effect I am after is very similar to the page translation feature that Google offers. Does anyone have any examples of this kind of technique. Any ideas how much work is involved? (My 'translation' is pretty trivial, so really it is mostly a question of how much work to display the remote page).
View Replies !
Parsing Remote Page And Outputting
Here is a general idea of what I want to do: HTML Form is submitted by remote user using POST methodVariables are received by 'search.php'Script within 'search.php' will POST same variables to a remote (3rd party) website Script downloads the resulting HTML pageScript parses HTML page and displays relevant data (ie. a specific table) I'm stuck at the part with the -- how would I get PHP to POST the user's vars to get the page returned? I know how to do this if I were using a GET method, but this is not an option.
View Replies !
Copy Remote Page To My Server
I have permission to use some data from a weather site, the page has a table, I strip the data I want and display on my site using php and format it to suit. I am retrieving about 60 bits of data from that page, this is now taking a few seconds, I was wondering if it is possible to copy the page locally and then I run my script. Is it possible to copy a page from a server to my site?
View Replies !
Call Remote PHP Script On HTML Page
I have (almost) completed a php script. The client has an existing site and the pages have some graphical elements that need to be there. Hence whenever the htm page is called, i want the php script to run at a particular location on the page and insert the result there before sending the page back to the user. I am trying to avoid having to copy and paste the php code onto every page and save all pages with the php extension. Do I (I am Java-speaking here) declare it as a class and the procedure as a method with parameters? and place the script in the cgi-bin. Then make an instance of it on the page and call the method and pass the parameters to the phh script from there?? i was not able to locate an 'import' declaration to achieve this.
View Replies !
Is It Possible To Read ASP.NET Web Page In PHP?
Is it possible to read another web page in PHP? If is ASP.NET, the code would be ------------ WebRequest req=WebRequest.Create("http://www.microsoft.com"); WebResponse res=req.GetResponse(); StreamReader sr = new StreamReader(res.GetResponseStream()); String Output=sr.ReadToEnd(); Response.Write("The content is : " + Output); --------
View Replies !
Read A Web Page
i want to store(read) the contents of a "web page" into a file. how can i do it in PHP. Please help me. The web page contains a table. i want to fetch & store the contents of that table into a file.
View Replies !
Find The File Name Of A Remote Site's Index Page
How do you find the file name of a remote site's index page using PHP...so, given that I have a domain name of www.yourSite.com, the file name might be: index.php index.htm index.html index.shtml index.cgi index.pl .....etc., etc.... How do I figure out which one it is?
View Replies !
Read A Web Page And Then Display
I'd like to read a webpage, the parse it and display a small part of it. Here is what I've tired. It isn't working. <?php $handle = fopen("http://www.yahoo.com/", "r"); $contents = fread($handle, filesize($filename)); echo $contents; ?>
View Replies !
Q: Read Text With VBA From A PHP Web-page
I created a page on our intranet that shows a number and that increases for every time the page is opened. It is similar to a visitors-counter. When I look at the page with Internet Explorer it works just fine. Now I want to read this web-page from a MS-Word macro and include the number as a company wide unique id in my MS-Word document. Unfortunately, the PHP script doesn't update the counter when I call it from my MS-Word macro. How can I force PHP to update my counter when I call it from a VBA macro? I am using the following code:
View Replies !
Read An HTML Page
It may sound kind of crazy, but I'm trying to see if there's a way php code can 'read' contents of a static HTML page and store the contents into a variable. Is it possible? If so, how?
View Replies !
|