Go Back   WarriorForum - Internet Marketing Forums > Warrior Support Forums > Programming Talk
Register Blogs FAQ Social Groups CalendarHelp Desk

Reply
 
LinkBack Thread Tools
Old 01-05-2010, 03:24 PM   #1
Warrior Member
 
Join Date: Jan 2010
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Social Networking View Member's Myspace Profile 
Contact Info
Send a message via AIM to rctelles
Default Hello World! My first program. (Ps not HW)

Hello all. So I am trying to write a simple script that will let me put forwarding on a godaddy domain for example forward-this-domain1 dot com to redirect-to-here dot com.

The php file can sit on the redirect-to-here dot com server and in godaddy i want to forward to say redirect-to-here dot com/ redirection/ index.php? domain=forward-this-domain1 dot com. I want this whole process to be logged.

So here is my first script written mostly by me ever.

PHP Code:
<?php

//variables
$logfile 'redirections.html';
$redir_url 'http: redirect-to-here dot com';
$IP $_SERVER['REMOTE_ADDR'];
$refer $_SERVER[''];

$domain = array("forward-this-domain1 dot com" => "forward-this2 dot com");

//set logfile output
$logdetails=  date("F j, Y, g:i a") . ': ' '<a href=http: network-tools dot com/default.asp?prog=whois&host='.$_SERVER['REMOTE_ADDR'].'>'.$_SERVER['REMOTE_ADDR'].'</a>' ' from domain ' $domain ' and referrer ' $refer;

//set var to open logfile
$fp fopen($logfile"a");

//main script
fwrite($fp$logdetails);
fwrite($fp"<br />");
fclose($fp);

header('Location:' $redir_url);
exit();

?>
And this is my output to "redirections dot html"

Code:
January 5, 2010, 3:09 pm: xx.xxx.xx.xxx from domain Array and referrer
January 5, 2010, 3:09 pm: xx.xxx.xx.xxx from domain Array and referrer ##Referral directory if called from a director with no index##
How do I make "Array" say the domain variable instead? The host refer does seem to work though when its called from an actual web page, but not when forwarded through a domain on godaddy.

Hope I make sense. And I hope I didnt fudge the code so bad lol. I thought it was going pretty well until it didnt do what I really wanted it to lol.

Ps. didnt mean to obscure the links so much but the forum thought I was trying to spam it. I dont know if any domain other than the network tool is active or owned.
rctelles is offline   Reply With Quote
Old 01-05-2010, 03:38 PM   #2
Warrior Member
 
Join Date: Jan 2010
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Social Networking View Member's Myspace Profile 
Contact Info
Send a message via AIM to rctelles
Default Re: Hello World! My first program. (Ps not HW)

What the duece? I guess it did let me post the code. I apologize for the double post.
rctelles is offline   Reply With Quote
Old 01-08-2010, 04:12 AM   #3
A rat after money...
War Room Member
 
HomeBizNizz's Avatar
 
Join Date: Jul 2009
Location: Inside a cheese...
Posts: 598
Thanks: 363
Thanked 54 Times in 47 Posts
Default Re: Hello World! My first program. (Ps not HW)

It is something wrong with the forum then you post code in the blogpost...

HomeBizNizz is offline   Reply With Quote
Old 01-08-2010, 05:06 AM   #4
HyperActive Warrior
War Room Member
 
Join Date: May 2009
Location: U.K
Posts: 197
Thanks: 5
Thanked 39 Times in 36 Posts
Social Networking View Member's Twitter Profile 
Default Re: Hello World! My first program. (Ps not HW)

Quote:
Originally Posted by rctelles View Post
Hello all. So I am trying to write a simple script that will let me put forwarding on a godaddy domain for example forward-this-domain1 dot com to redirect-to-here dot com.

How do I make "Array" say the domain variable instead? The host refer does seem to work though when its called from an actual web page, but not when forwarded through a domain on godaddy.
The problem is the way you are echoing the domain value; arrays are somewhat more complex that a standard variable, think of them as a collection of variables. In this case, your associative array;

The value of $domain has no value - since it is an array.
The value of $domain[''forward-this-domain1 dot com'] is 'forward-this2 dot com'

This is why you are getting "Array" as the output.

You need to output is as the above;

$logdetails= date("F j, Y, g:i a") . ': ' . '<a href=http: network-tools dot com/default.asp?prog=whois&host='.$_SERVER['REMOTE_ADDR'].'>'.$_SERVER['REMOTE_ADDR'].'</a>' . ' from domain ' . $domain['forward-this-domain1 dot com'] . ' and referrer ' . $refer;

Assuming you are only working with the one element in your array.

If you have more elements in the array, you will need to work out what array key you need to use. In your example above, this is as easy as;

$requested_url=$_GET['domain'];

$logdetails= date("F j, Y, g:i a") . ': ' . '<a href=http: network-tools dot com/default.asp?prog=whois&host='.$_SERVER['REMOTE_ADDR'].'>'.$_SERVER['REMOTE_ADDR'].'</a>' . ' from domain ' . $domain[$requested_url] . ' and referrer ' . $refer;


Disclaimer: You should check the value that is stored in $_GET['domain'] is valid or you may end up with some unexpected results. Always clean the data, and check its what you are expecting. In this case, you can check if the requested domain exists in your array by using the array_key_exists function.

Best Ways To Make Money Online

Eight bytes walk into a bar. The bartender asks, “Can I get you anything?”
“Yeah,” reply the bytes. “Make us a double.”
Luke Graham is offline   Reply With Quote
Old 01-09-2010, 11:52 PM   #5
Crazy Internet Marketer
War Room Member
 
saschakimmel's Avatar
 
Join Date: Jan 2010
Location: Germany
Posts: 101
Thanks: 0
Thanked 15 Times in 12 Posts
Social Networking View Member's FaceBook Profile  View Member's Twitter Profile 
Contact Info
Send a message via ICQ to saschakimmel Send a message via Skype™ to saschakimmel
Default Re: Hello World! My first program. (Ps not HW)

If SEO is important to you you should add this header right before the "Location" header is sent to the browser:
header("HTTP/1.0 301 Moved Permanently");

As chaos69 has written - always check the values for the domain - otherwise it could easily be used to redirect to SPAM domains by spammers with your domain name in the URL.

** Get my ViralListMachine software now for free and build your own list virally by giving away free stuff @ http://www.virallistmachinegiveaway.com **
saschakimmel is offline   Reply With Quote
Old 01-10-2010, 12:09 AM   #6
Warrior Member
 
Join Date: Jan 2010
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Social Networking View Member's Myspace Profile 
Contact Info
Send a message via AIM to rctelles
Default Re: Hello World! My first program. (Ps not HW)

Thanks for both your advice. Isnt SEO important to everyone?! hehe. I been really busy the last couple days but I will definitely fool around with the suggestions yall made. Thanks again!
rctelles is offline   Reply With Quote
Reply

  WarriorForum - Internet Marketing Forums > Warrior Support Forums > Programming Talk

Tags
program, world

Thread Tools

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



All times are GMT -6. The time now is 04:51 AM.