Closed Thread
Results 1 to 8 of 8
Like Tree3Likes
  • 1 Post By oceanwap
  • 2 Post By galaxyAbstractor

Thread: getallheaders() is disabled, why?

  1. #1
    oceanwap's Avatar
    oceanwap is offline x10Hosting Member oceanwap is an unknown quantity at this point
    Join Date
    Nov 2009
    Location
    India
    Posts
    24

    getallheaders() is disabled, why?

    I am developing a mobile site.For this I want to know request headers from visting browsers and want to log them.So I can design a mechanism where I can detect handset browsers name(User agent) and serve content according to this.
    As you might know that there are plenty of mobile browsers, along with some transcoders(like "http://m.google.com/gwt/n" and "Opera mini").
    Normal phone browsers user-agent can be accessed using $_SERVER['HTTP_USER_AGENT'], but transcoders sends their own headers for example, if I want to know original user-agent of opera mini host, then I need to access different header $_SERVER['HTTP_X_OPERAMINI_PHONE_UA'].and something similar for IP address.
    I searched through internet so I got these headers.But there are plenty of mobile networks and 3rd party browsers who are doing this.So it will be good, if I store these headers this server temperoraily and study them on so I can design best detection system.I am using WURFL framework.But it is not good at detecting transcoders(means:- who modify original headers,sometimes mobile networks do this too,like vodaone UK).
    So I wrote this to get header info
    PHP Code:
    <?php
    $file_name
    ="welcome.html";
    foreach (
    apache_request_headers() as $name => $value
    {
    $body_content=$value;
    $fp=fopen($file_name,"a");
    fwrite ($fp,$body_content);          // entering data to the file
    fclose ($fp);                                // closing the file pointer
    chmod($file_name,0777);
    }
    ?>
    But neither apache_request_headers() nor getallheaders() is working on my free account.I am new to php programming(only 1 month experience).So I want to know what is the reason behind these functions are unfunctionalty and what could be the solution for my problem.
    Last edited by oceanwap; 01-04-2010 at 05:44 AM. Reason: Grammer & spelling mistakes
    dinomirt96 likes this.

  2. #2
    galaxyAbstractor's Avatar
    galaxyAbstractor is offline Community Advocate galaxyAbstractor is on a distinguished road
    Join Date
    Oct 2007
    Location
    Land of Null and Insanity
    Posts
    5,495

    Re: getallheaders() is disabled, why?

    getallheaders() only works when PHP is installed as an Apache module on the servers, which in this case it isn't. So best bet is to try to find an alternate way of getting them.

    Could you see if this works:

    PHP Code:
    <?php
    function emu_getallheaders() {
       foreach(
    $_SERVER as $name => $value)
           if(
    substr($name05) == 'HTTP_')
               
    $headers[str_replace(' ''-'ucwords(strtolower(str_replace('_'' 'substr($name5)))))] = $value;
       return 
    $headers;
    }
    ?>
    Call emu_getallheaders() instead of getallheaders()
    Last edited by galaxyAbstractor; 01-04-2010 at 04:44 AM.
    verlmirt17 and karimirt47 like this.

  3. #3
    oceanwap's Avatar
    oceanwap is offline x10Hosting Member oceanwap is an unknown quantity at this point
    Join Date
    Nov 2009
    Location
    India
    Posts
    24

    Re: getallheaders() is disabled, why?

    Thanks for info but the output I am getting is just information inside headers.But I want information plus headers name.Because headers are case sensitive.And greedy mobile operators and proxy services changes them.So I want to know what is the name of headers they are sending and its value.

  4. #4
    Gouri's Avatar
    Gouri is offline Community Paragon Gouri has a brilliant futureGouri has a brilliant futureGouri has a brilliant future
    Join Date
    Oct 2007
    Location
    India
    Posts
    4,502

    Re: getallheaders() is disabled, why?

    Hi oceanwap,

    It gives the header name too.

    Check it.


    PHP Code:
    function emu_getallheaders() {
       foreach(
    $_SERVER as $name => $value)
           if(
    substr($name05) == 'HTTP_')
               
    $headers[str_replace(' ''-'ucwords(strtolower(str_replace('_'' 'substr($name5)))))] = $value;
       return 
    $headers;
    }

    $headers emu_getallheaders();

    foreach (
    $headers as $header => $value) {
        echo 
    "$header$value <br />\n";

    If you feel my post is useful then click to give Reputation (bottom left corner of this post)

    X10 Hosting | News and Announcements | Premium Hosting | VPS Hosting | Prime Membership

    Tech Community | Gouri

  5. #5
    oceanwap's Avatar
    oceanwap is offline x10Hosting Member oceanwap is an unknown quantity at this point
    Join Date
    Nov 2009
    Location
    India
    Posts
    24

    Re: getallheaders() is disabled, why?

    Thanks a lot, It is working perfectly now.Now the only work left is store each $header: $value <br />\n to a file so that I can save this information.And I did this like this
    PHP Code:
    <?php
    function emu_getallheaders() {
       foreach(
    $_SERVER as $name => $value)
           if(
    substr($name05) == 'HTTP_')
               
    $headers[str_replace(' ''-'ucwords(strtolower(str_replace('_'' 'substr($name5)))))] = $value;
       return 
    $headers;
    }
    $headers emu_getallheaders();
    $file_name="welcome.html";
    foreach (
    emu_getallheaders() as $name => $value) {
    $body_content="$name$value";
    $add_line_break='<br />';
    $fp=fopen($file_name,"a");
    fwrite ($fp,$body_content.$add_line_break);          // entering data to the file
    fclose ($fp);                                // closing the file pointer
    chmod($file_name,0777);
    }
    ?>
    Last edited by oceanwap; 01-04-2010 at 06:44 AM.

  6. #6
    Gouri's Avatar
    Gouri is offline Community Paragon Gouri has a brilliant futureGouri has a brilliant futureGouri has a brilliant future
    Join Date
    Oct 2007
    Location
    India
    Posts
    4,502

    Re: getallheaders() is disabled, why?

    Quote Originally Posted by oceanwap View Post
    Thanks a lot, It is working perfectly now.Now the only work left is store each $header: $value <br />\n to a file so that I can save this information.And I did this like this
    Instead of opening the file for every header field, Open the file outside the for loop and close the file after the for loop.

    PHP Code:
    <?php
    function emu_getallheaders() {
       foreach(
    $_SERVER as $name => $value)
           if(
    substr($name05) == 'HTTP_')
               
    $headers[str_replace(' ''-'ucwords(strtolower(str_replace('_'' 'substr($name5)))))] = $value;
       return 
    $headers;
    }
    $headers emu_getallheaders();
    $file_name="welcome.html";
    $fp=fopen($file_name,"a");
    foreach (
    emu_getallheaders() as $name => $value) {
    $body_content="$name$value";
    $add_line_break='<br />';
    fwrite ($fp,$body_content.$add_line_break);          // entering data to the file
    }
    fclose ($fp);                                // closing the file pointer
    chmod($file_name,0755);
    ?>
    But It is recommended to store the information in MySQL database. And when ever required display from the database.
    If you feel my post is useful then click to give Reputation (bottom left corner of this post)

    X10 Hosting | News and Announcements | Premium Hosting | VPS Hosting | Prime Membership

    Tech Community | Gouri

  7. #7
    oceanwap's Avatar
    oceanwap is offline x10Hosting Member oceanwap is an unknown quantity at this point
    Join Date
    Nov 2009
    Location
    India
    Posts
    24

    Re: getallheaders() is disabled, why?

    Again thanks for your suggestion.Opening and closing file in a loop is not a good idea,But free account has limitation of 3 databases.Suppose I have a joomla database,so can I use that to create tables for this header detection system.or I should create new one.

  8. #8
    xav0989's Avatar
    xav0989 is online now Community Public Relation xav0989 is just really nice
    Join Date
    Jul 2008
    Location
    ifk
    Posts
    4,436

    Re: getallheaders() is disabled, why?

    Quote Originally Posted by oceanwap View Post
    Again thanks for your suggestion.Opening and closing file in a loop is not a good idea,But free account has limitation of 3 databases.Suppose I have a joomla database,so can I use that to create tables for this header detection system.or I should create new one.
    You can put an almost unlimited number of tables inside a single database. Simply make sure that there is no name conflict and you can easily use the same database to store the headers.

    - xav0989
    Xavier L | Community Public Relations Manager (Free Hosting Support)
    █ Yes, my position is too cool to even exist!
    How am I helping? Rate this post by clicking the icon below! (this is even better than "liking" a post)
    Terms of Service | Acceptable Use Policy | x10Hosting Wiki

Closed Thread

Similar Threads

  1. ()phpinfo disabled? It was never disabled
    By brianxp in forum Free Hosting
    Replies: 4
    Last Post: 06-12-2009, 04:36 AM
  2. php mail() function is disabled?? still not working??
    By multipass in forum Free Hosting
    Replies: 3
    Last Post: 09-04-2008, 10:14 AM
  3. error - disabled for security reasons
    By netley in forum Free Hosting
    Replies: 1
    Last Post: 08-17-2008, 07:16 PM
  4. mail() disabled
    By hetster in forum Free Hosting
    Replies: 1
    Last Post: 04-22-2008, 03:12 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers