Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-13-2009, 05:09 PM   PM User | #1
matafy
New Coder

 
Join Date: Apr 2009
Posts: 59
Thanks: 13
Thanked 0 Times in 0 Posts
matafy is an unknown quantity at this point
[NEED HELP] Calling a function to it's proper place

Can someone please help with my function problem?

PHP Code:
<?PHP

$ip 
= array(); 
$hours_offset 0// Server time offset

//-------------- Video IDs ------------------------------------- 
/* Monday 09:00 AM to 09:00 PM */

$ip['Mon09'] = "168.0.0.1";    // Cam #1
$ip['Mon10'] = "168.0.0.2";    // Cam #2
$ip['Mon11'] = "168.0.0.3";    // Cam #3
$ip['Mon12'] = "168.0.0.4";    // Cam #4
$ip['Mon13'] = "168.0.0.5";    // Cam #5
$ip['Mon14'] = "168.0.0.6";    // Cam #6
$ip['Mon15'] = "168.0.0.7";    // Cam #7
$ip['Mon16'] = "168.0.0.8";    // Cam #8
$ip['Mon17'] = "168.0.0.9";    // Cam #9
$ip['Mon18'] = "168.0.0.10";   // Cam #10
$ip['Mon19'] = "168.0.0.11";   // Cam #11
$ip['Mon20'] = "168.0.0.12";   // Cam #12
$ip['Mon21'] = "168.0.0.13";   // Cam #13
 
//-------------------------------------------------------------- 

$defaults = array("168.0.0.14","168.0.0.15","168.0.0.16","168.0.0.17","168.0.0.18","168.0.0.19"); // Flash Commercials
$ip['default'] = $defaults[array_rand($defaults)];

function 
getIPAddress() { 
  global 
$ip,$hours_offset
  
$check date("DH",(time()-(3600*$hours_offset)));
  if (isset(
$ip[$check])) return $ip[$check]; 
  else return 
$ip['default']; 


$port="8080";
if (
$_SERVER['REMOTE_ADDR']==$ip || $_SERVER['REMOTE_ADDR']=="127.0.0.1")
{

}
  
$rr rand(1,32767);    
  print 
"<PARAM NAME=allowFlashAutoInstall VALUE=true>\r\n";
  print 
"<param name=Flashvars value='url=http://$ip:$port/a$rr.flv'>\r\n"// I ran it through my server and it doesn't come up with the target ip address...
  
print "<param name='movie' value='popup.swf' />\r\n";
  print 
"<param name='quality' value='high' />\r\n";
  print 
"<param name='bgcolor' value='#000000' />\r\n";
  print 
"<embed src='popup.swf' swLiveConnect='true' Flashvars='url=http://$ip:$port/a$rr.flv' quality='high'\r\n"// Same here
  
print "bgcolor='000000' width='320' height='240' name='popup' align='middle'\r\n";
  print 
"type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />\r\n";
  print 
"</object>\r\n";
?>
matafy is offline   Reply With Quote
Old 10-13-2009, 05:24 PM   PM User | #2
venegal
Gütkodierer


 
Join Date: Apr 2009
Posts: 2,127
Thanks: 1
Thanked 426 Times in 424 Posts
venegal has a spectacular aura aboutvenegal has a spectacular aura about
Like already mentioned, you don't call your getIPAddress function anywhere.
Somewhere there should be something like
PHP Code:
$currentIP getIPAddress(); 
and you should then use $currentIP instead of $ip (which, in your case, is the array holding all the ip addresses, although your code is expecting one single ip address).
venegal is offline   Reply With Quote
Users who have thanked venegal for this post:
matafy (10-13-2009)
Old 10-13-2009, 07:12 PM   PM User | #3
oracleguy
Rockstar Coder


 
Join Date: Jun 2002
Location: USA
Posts: 9,043
Thanks: 1
Thanked 322 Times in 318 Posts
oracleguy is a jewel in the roughoracleguy is a jewel in the roughoracleguy is a jewel in the rough
You might get more help if you actually explained what wasn't working right in detail and any errors you are getting.
__________________
OracleGuy
oracleguy is offline   Reply With Quote
Old 10-13-2009, 11:06 PM   PM User | #4
matafy
New Coder

 
Join Date: Apr 2009
Posts: 59
Thanks: 13
Thanked 0 Times in 0 Posts
matafy is an unknown quantity at this point
Unhappy

This is what I have so far.

PHP Code:
<?PHP

$currentIP 
getIPAddress(); 
$hours_offset 0// Server time offset

//-------------- Current IP Address ---------------------------- 
/* Monday 09:00 AM to 09:00 PM */

$currentIP['Mon09'] = "168.0.0.1";    // Cam #1
$currentIP['Mon10'] = "168.0.0.2";    // Cam #2
$currentIP['Mon11'] = "168.0.0.3";    // Cam #3
$currentIP['Mon12'] = "168.0.0.4";    // Cam #4
$currentIP['Mon13'] = "168.0.0.5";    // Cam #5
$currentIP['Mon14'] = "168.0.0.6";    // Cam #6
$currentIP['Mon15'] = "168.0.0.7";    // Cam #7
$currentIP['Mon16'] = "168.0.0.8";    // Cam #8
$currentIP['Mon17'] = "168.0.0.9";    // Cam #9
$currentIP['Mon18'] = "168.0.0.10";   // Cam #10
$currentIP['Mon19'] = "168.0.0.11";   // Cam #11
$currentIP['Mon20'] = "168.0.0.12";   // Cam #12
$currentIP['Mon21'] = "168.0.0.13";   // Cam #13
 
//-------------------------------------------------------------- 

$defaults = array("168.0.0.14","168.0.0.15","168.0.0.16","168.0.0.17","168.0.0.18","168.0.0.19"); // Flash Commercials
$currentIP['default'] = $defaults[array_rand($defaults)];

function 
getIPAddress() { 
  global 
$currentIP,$hours_offset
  
$check date("DH",(time()-(3600*$hours_offset)));
  if (isset(
$currentIP[$check])) return $currentIP[$check]; 
  else return 
$currentIP['default']; 


$port="8080";
if (
$_SERVER['REMOTE_ADDR']==$currentIP || $_SERVER['REMOTE_ADDR']=="127.0.0.1")
{

}
  
$rr rand(1,32767);    
  print 
"<PARAM NAME=allowFlashAutoInstall VALUE=true>\r\n";
  print 
"<param name=Flashvars value='url=http://$currentIP:$port/a$rr.flv'>\r\n"// I ran it through my server and it doesn't come up with the target ip address...
  
print "<param name='movie' value='popup.swf' />\r\n";
  print 
"<param name='quality' value='high' />\r\n";
  print 
"<param name='bgcolor' value='#000000' />\r\n";
  print 
"<embed src='popup.swf' swLiveConnect='true' Flashvars='url=http://$currentIP:$port/a$rr.flv' quality='high'\r\n"// Same here
  
print "bgcolor='000000' width='320' height='240' name='popup' align='middle'\r\n";
  print 
"type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />\r\n";
  print 
"</object>\r\n";
?>
When I ran this one through it returned this
PHP Code:
<PARAM NAME=allowFlashAutoInstall VALUE=true>
<
param name=Flashvars value='url=http://Array:8080/a32685.flv'>
<
param name='movie' value='popup.swf' />
<
param name='quality' value='high' />
<
param name='bgcolor' value='#000000' />
<
embed src='popup.swf' swLiveConnect='true' Flashvars='url=http://Array:8080/a32685.flv' quality='high'
bgcolor='000000' width='320' height='240' name='popup' align='middle'
type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />
</
object
My goal is to put the ip address in place of the word "Array" that is located on the 2nd line. I have tried echoing the getIPAddress function but it screws up the php code.
matafy is offline   Reply With Quote
Old 10-13-2009, 11:15 PM   PM User | #5
venegal
Gütkodierer


 
Join Date: Apr 2009
Posts: 2,127
Thanks: 1
Thanked 426 Times in 424 Posts
venegal has a spectacular aura aboutvenegal has a spectacular aura about
That's what I meant:

PHP Code:
<?PHP

$ip 
= array(); 
$hours_offset 0// Server time offset

//-------------- Video IDs ------------------------------------- 
/* Monday 09:00 AM to 09:00 PM */

$ip['Mon09'] = "168.0.0.1";    // Cam #1
$ip['Mon10'] = "168.0.0.2";    // Cam #2
$ip['Mon11'] = "168.0.0.3";    // Cam #3
$ip['Mon12'] = "168.0.0.4";    // Cam #4
$ip['Mon13'] = "168.0.0.5";    // Cam #5
$ip['Mon14'] = "168.0.0.6";    // Cam #6
$ip['Mon15'] = "168.0.0.7";    // Cam #7
$ip['Mon16'] = "168.0.0.8";    // Cam #8
$ip['Mon17'] = "168.0.0.9";    // Cam #9
$ip['Mon18'] = "168.0.0.10";   // Cam #10
$ip['Mon19'] = "168.0.0.11";   // Cam #11
$ip['Mon20'] = "168.0.0.12";   // Cam #12
$ip['Mon21'] = "168.0.0.13";   // Cam #13
 
//-------------------------------------------------------------- 

$defaults = array("168.0.0.14","168.0.0.15","168.0.0.16","168.0.0.17","168.0.0.18","168.0.0.19"); // Flash Commercials
$ip['default'] = $defaults[array_rand($defaults)];

function 
getIPAddress() { 
  global 
$ip,$hours_offset
  
$check date("DH",(time()-(3600*$hours_offset)));
  if (isset(
$ip[$check])) return $ip[$check]; 
  else return 
$ip['default']; 


$currentIP getIPAddress();
$port="8080";
if (
$_SERVER['REMOTE_ADDR']==$currentIP || $_SERVER['REMOTE_ADDR']=="127.0.0.1")
{

}
  
$rr rand(1,32767);    
  print 
"<PARAM NAME=allowFlashAutoInstall VALUE=true>\r\n";
  print 
"<param name=Flashvars value='url=http://$currentIP:$port/a$rr.flv'>\r\n"// I ran it through my server and it doesn't come up with the target ip address...
  
print "<param name='movie' value='popup.swf' />\r\n";
  print 
"<param name='quality' value='high' />\r\n";
  print 
"<param name='bgcolor' value='#000000' />\r\n";
  print 
"<embed src='popup.swf' swLiveConnect='true' Flashvars='url=http://$currentIP:$port/a$rr.flv' quality='high'\r\n"// Same here
  
print "bgcolor='000000' width='320' height='240' name='popup' align='middle'\r\n";
  print 
"type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />\r\n";
  print 
"</object>\r\n";
?>
venegal is offline   Reply With Quote
Old 10-14-2009, 06:49 AM   PM User | #6
matafy
New Coder

 
Join Date: Apr 2009
Posts: 59
Thanks: 13
Thanked 0 Times in 0 Posts
matafy is an unknown quantity at this point
Smile Perfect! One question though...

I ran it through my server and it worked perfectly, but I also saw this "".
PHP Code:
<PARAM NAME=allowFlashAutoInstall VALUE=true>
<
param name=Flashvars value='url=http://168.0.0.16:8080/a356.flv'>
<
param name='movie' value='popup.swf' />
<
param name='quality' value='high' />
<
param name='bgcolor' value='#000000' />
<
embed src='popup.swf' swLiveConnect='true' Flashvars='url=http://168.0.0.16:8080/a356.flv' quality='high'
bgcolor='000000' width='320' height='240' name='popup' align='middle'
type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />
</
object
What does "" mean?
matafy is offline   Reply With Quote
Old 10-14-2009, 10:52 AM   PM User | #7
venegal
Gütkodierer


 
Join Date: Apr 2009
Posts: 2,127
Thanks: 1
Thanked 426 Times in 424 Posts
venegal has a spectacular aura aboutvenegal has a spectacular aura about
It's the UTF-8 byte order mark. It's there because your editor handles the code file as UTF-8 while the browser treats it as ISO-8859-1.

Just make sure that those two encodings are the same, so either change your editor to ISO-8859-1 and delete those characters, or tell the browser what's going on with <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />.
venegal is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 08:22 AM.


Advertisement
Log in to turn off these ads.