Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Apr 2009
    Posts
    59
    Thanks
    13
    Thanked 0 Times in 0 Posts

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

  • #2
    Gütkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    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).

  • Users who have thanked venegal for this post:

    matafy (10-13-2009)

  • #3
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    You might get more help if you actually explained what wasn't working right in detail and any errors you are getting.
    OracleGuy

  • #4
    New Coder
    Join Date
    Apr 2009
    Posts
    59
    Thanks
    13
    Thanked 0 Times in 0 Posts

    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.

  • #5
    Gütkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    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";
    ?>

  • #6
    New Coder
    Join Date
    Apr 2009
    Posts
    59
    Thanks
    13
    Thanked 0 Times in 0 Posts

    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?

  • #7
    Gütkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    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" />.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •