Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 06-05-2007, 10:44 PM help on taking url
Skilled Talker

Posts: 70
Name: rex
Trades: 0

i have this situation:

1. i have a textbox for the user to encode the url
2. by $_POST['x'] ill evaluate the url if valid or not using
file_get_contents().
if(!file_get_contents($x){
// do actions here..
}

however i dont know if what is wrong, file_get_contents() works
perfectly on
my local machine but upon loading to our webserver, it doesn't work
at all.

3. the next action is to $x as param value 'http://www.my...com?url='.
$x.
now this url will then dynamically produce another url. and that
new url is
the one that i want to get and assigned it to a string.

but i want all process to be totally invisible to the user. because
after
successfully getting the new url i post a message like your new url
is ...
is this possible? how to do this?

tnx
shotokan99 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-05-2007, 11:06 PM Re: help on taking url
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
I don't understand your last question, but as for why file_get_contents isn't working, you should make sure that your server has allow_url_fopen set to on. Some servers have this off.
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 06-06-2007, 02:10 AM Re: help on taking url
Skilled Talker

Posts: 70
Name: rex
Trades: 0
i think yes, because on my local server it is set to on. i also tried fopen and get_header still the same works fine on my local machine but doesnt upon uploading.

is there another way for me to check the validity of the url that doesnt reli with allow_url_open?

regarding my last question. i already check the url is valid, and it's a yes. next i will use this url as a parameter for a certain site www.mysite.com?url=..... after passing the parameter mysite.com will then produce a dynamic url, and i want to get the value of this new url.
shotokan99 is offline
Reply With Quote
View Public Profile
 
Old 06-06-2007, 11:02 AM Re: help on taking url
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
For your file_get_contents issue, you'd need to give an error message or more info. Your claim is that the code works on one server and not the other. That's not usually because of the code, but because of different server configurations.

For a URL of the form www.mysite.com?url= , you'll have trouble as that's not correctly formatted. At a minimum it should look like www.mysite.com/?url= at which point the default index script will be run (usually index.html or index.php). If it's an HTML or other file, I can't help you (HTML cannot access stuff server side without SSI afaik). If it's PHP, the URL is available as $_GET['url']
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Old 06-06-2007, 12:23 PM Re: help on taking url
Average Talker

Posts: 25
Name: Jason R
Trades: 0
check phpInfo() on your server if will tell you how allow_url_open is set.

-JasonR
JasonR is offline
Reply With Quote
View Public Profile Visit JasonR's homepage!
 
Old 06-06-2007, 10:06 PM Re: help on taking url
Skilled Talker

Posts: 70
Name: rex
Trades: 0
so if allow_url_open is off is there another way for me to check if that certain is valid or not?
shotokan99 is offline
Reply With Quote
View Public Profile
 
Old 06-06-2007, 10:39 PM Re: help on taking url
Average Talker

Posts: 25
Name: Jason R
Trades: 0
You should be able to do it with CURL. Most implementations I have see with open URL off still allow CURL.

-JasonR
__________________

Please login or register to view this content. Registration is FREE
- 15,000+ new domaina names a day starting at $5.

Please login or register to view this content. Registration is FREE
- Personal Site/Script Portfolio
JasonR is offline
Reply With Quote
View Public Profile Visit JasonR's homepage!
 
Old 06-06-2007, 10:42 PM Re: help on taking url
Experienced Talker

Posts: 31
Trades: 0
Maybe with Fsock Open
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
tjtravis is offline
Reply With Quote
View Public Profile
 
Old 06-06-2007, 11:12 PM Re: help on taking url
Skilled Talker

Posts: 70
Name: rex
Trades: 0
can you please tell me how to use curl or fsock? if possible just a simple example
shotokan99 is offline
Reply With Quote
View Public Profile
 
Old 06-07-2007, 07:34 AM Re: help on taking url
Junior Talker

Posts: 1
Name: Nick Bonetti
Trades: 0
Quote:
Originally Posted by shotokan99 View Post
can you please tell me how to use curl or fsock? if possible just a simple example
Hi man - here is curl example
PHP Code:
<?php
$url
="http://www.your-url-address";
$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,'$url');
curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2);
curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1);
$buffer curl_exec($curl_handle);
curl_close($curl_handle);
if (empty(
$buffer))
{
    print 
"Sorry - no content.<p>";
}
else
{
    echo 
"<h1>HERE IS CONTENT:</h1><hr> $buffer";
}
?>
__________________

Please login or register to view this content. Registration is FREE

Last edited by hostingon; 06-07-2007 at 07:37 AM..
hostingon is offline
Reply With Quote
View Public Profile
 
Old 06-08-2007, 10:34 PM Re: help on taking url
Skilled Talker

Posts: 70
Name: rex
Trades: 0
@hostingon
i tried your sample code and it always give "sorry no content" even if i gave a valid url. what have gone wrong?
shotokan99 is offline
Reply With Quote
View Public Profile
 
Old 06-11-2007, 11:06 PM Re: help on taking url
Skilled Talker

Posts: 70
Name: rex
Trades: 0
our hosting support said..this can be achieved using .htaccess is it possible? how?
shotokan99 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to help on taking url
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.41650 seconds with 12 queries