...

View Full Version : [NEED HELP] Calling a function to it's proper place



matafy
10-13-2009, 05:09 PM
Can someone please help with my function problem?


<?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";
?>

venegal
10-13-2009, 05:24 PM
Like already mentioned, you don't call your getIPAddress function anywhere.
Somewhere there should be something like


$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).

oracleguy
10-13-2009, 07:12 PM
You might get more help if you actually explained what wasn't working right in detail and any errors you are getting.

matafy
10-13-2009, 11:06 PM
This is what I have so far.


<?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

<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.

venegal
10-13-2009, 11:15 PM
That's what I meant:



<?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";
?>

matafy
10-14-2009, 06:49 AM
I ran it through my server and it worked perfectly, but I also saw this "".

<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?

venegal
10-14-2009, 10:52 AM
It's the UTF-8 byte order mark (http://en.wikipedia.org/wiki/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" />.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum