Could someone take a look at my site and tell me what is wrong? I think it is PHP.

Discussion in 'PHP' started by Imozeb, Mar 13, 2012.

  1. #1
    Last edited: Mar 13, 2012
    Imozeb, Mar 13, 2012 IP
  2. ROOFIS

    ROOFIS Well-Known Member

    Messages:
    1,234
    Likes Received:
    30
    Best Answers:
    5
    Trophy Points:
    120
    #2

    000webhost.com/order.php <== ?? you get what you paid for, apart from that I saw no problem, page loaded aok :)

    Just watch your SEO though as 000webhost will drop in a cloaked anchor pointing to their site when googlebots crawl (you'll see this in google's cache)



    You get what you paid for!
     
    ROOFIS, Mar 13, 2012 IP
  3. wtd1

    wtd1 Peon

    Messages:
    58
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    " ... getting a bunch of PHP errors."

    You might want to be a little more specific.

    I clicked around on it, found no problem.
    I also use 000webhost at times, have never had a problem with them.
     
    wtd1, Mar 13, 2012 IP
  4. Imozeb

    Imozeb Peon

    Messages:
    666
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Sorry. Here is the link for the website: http://thethoughttreasury.host56.com/
    The PHP Errors are displaying on the page because I set error to show.

    ERRORS AT TOP OF PAGE:


    PHP Error Message

    Warning: is_dir() [function.is-dir]: open_basedir restriction in effect. File(/usr/local/apache/htdocs/cache) is not within the allowed path(s): (/home/:/usr/lib/php:/tmp) in /home/a4029522/public_html/include/class.Cache.php on line 64

    Free Web Hosting

    PHP Error Message

    Warning: mkdir() [function.mkdir]: open_basedir restriction in effect. File(/usr/local/apache/htdocs/cache) is not within the allowed path(s): (/home/:/usr/lib/php:/tmp) in /home/a4029522/public_html/include/class.Cache.php on line 66

    Free Web Hosting

    PHP Error Message

    Warning: fopen() [function.fopen]: open_basedir restriction in effect. File(/usr/local/apache/htdocs/cache/index.html) is not within the allowed path(s): (/home/:/usr/lib/php:/tmp) in /home/a4029522/public_html/include/class.Cache.php on line 67

    Free Web Hosting

    PHP Error Message

    Warning: fopen(/usr/local/apache/htdocs/cache/index.html) [function.fopen]: failed to open stream: Operation not permitted in /home/a4029522/public_html/include/class.Cache.php on line 67

    Free Web Hosting
     
    Imozeb, Mar 14, 2012 IP
  5. ttyler333

    ttyler333 Member

    Messages:
    62
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #5
    If you read it, it mentions that there is a restriction in effect. You could try and contact your host however odds are they have it restricted for security purposes.
     
    ttyler333, Mar 14, 2012 IP
  6. stephan2307

    stephan2307 Well-Known Member

    Messages:
    1,277
    Likes Received:
    33
    Best Answers:
    7
    Trophy Points:
    150
    #6
    My bet is that the paths are wrong
     
    stephan2307, Mar 14, 2012 IP
  7. wtd1

    wtd1 Peon

    Messages:
    58
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    On 000webhost a lot of the PHP fiunctions aren't available if you use your own domain name. They magically become available if you sign up for paid hosting. They're available if you use their subdomain.
    I bumped into this trying to modify a db from what they consider an 'external' site. It's annoying, if you develop on their site using their sub domain and everything works, then you get your own domain name and suddenly half your stuff doesn't work.

    I've seen that fopen() isn't available, the other functions you have errors on are of a similar nature, so I'd guess that's the problem.

    To find out what functions are available this could help -

    <?php phpinfo(); ?>

    put this in a file, put it on your site and run it
    it shoudl list all the fucntions that are available to you.

    But you'll just have to code around the limitations unless you want to get the paid hosting.
    Personally I just found it cheaper and easier to stick with free hosting and code around.
    They have a FAQ page that explains this somewhat, but it's hard to find - the easiest way is to google "FAQ 000webhost".
     
    wtd1, Mar 14, 2012 IP
  8. Imozeb

    Imozeb Peon

    Messages:
    666
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Any idea for a code around?

    Here is a link to my PHP info: http://thethoughttreasury.host56.com/test.php

    Someone said I should change:

    In your class.Cache.php file, there might be a code defining your document root. The document
    root defined in php configuration is '/usr/local/apache/htdocs', while your actual document root
    is '/home/account#/public_html' directory. So, you need to change your code something like:

    From:
    $doc_root= $_SERVER['DOCUMENT_ROOT'];

    To:
    $doc_root = dirname(_FILE_);



    Is this right? If so what do I change in this script?

    This is my Class.cache file:

    <?php
    /************************************************** *****************
    / ProArcadeScript
    / File description:
    / Implementation of the CCache class
    /
    /************************************************** *****************/


    //-----------------------------------------------------------------------------------------
    // helper function which recursively removes a directory
    //
    // to use this function to totally remove a directory, write:
    // remove_directory('path/to/directory/to/delete');
    // to use this function to empty a directory, write:
    // remove_directory('path/to/full_directory',TRUE);
    //-----------------------------------------------------------------------------------------
    function remove_directory( $directory, $empty=FALSE )
    {
    if(substr($directory,-1) == '/')
    $directory = substr($directory,0,-1);
    if(!file_exists($directory) || !is_dir($directory))
    return FALSE;
    elseif(is_readable($directory))
    {
    $handle = opendir($directory);
    while (FALSE !== ($item = readdir($handle)))
    {
    if($item != '.' && $item != '..')
    {
    $path = $directory.'/'.$item;
    if(is_dir($path))
    remove_directory($path);
    else
    unlink($path);
    }
    }
    closedir($handle);
    if($empty == FALSE)
    if(!rmdir($directory))
    return FALSE;
    }
    return TRUE;
    }





    //-----------------------------------------------------------------------------------------
    // Class CCache
    //-----------------------------------------------------------------------------------------
    class CCache
    {
    var $ttl = 2000; // Time to leave, seconds
    var $cache_root = '';
    var $enabled = false;

    //-----------------------------------------------------------------------------------------
    function CCache()
    {
    $path = $_SERVER['DOCUMENT_ROOT'] . $GLOBALS['cSite']['sSiteRoot'] . 'cache';
    $this->ttl = $GLOBALS['cSite']['cacheTTL'];
    if( !is_dir($path) )
    {
    mkdir( $path, 0775 );
    $file = fopen( $path . '/index.html', 'w' );
    if( $file )
    {
    fwrite( $file, ' ' );
    fclose( $file );
    }
    }
    $this->cache_root = "$path/";
    $this->enabled = $GLOBALS["cSite"]["bCache"];
    }

    //-----------------------------------------------------------------------------------------
    function get()
    {
    if( !$this->enabled )
    return false;

    $name = $_SERVER['REQUEST_URI'];
    $ext = $_SESSION['user'];
    $hash = sha1($name);
    $hash_ext = sha1($ext);
    $cache_dir = substr( $hash, 0, 5 );
    $cache_subdir = substr( $hash, 5, 5 );
    $time = date( 'U' );
    $cache_file = $this->cache_root . $cache_dir . '/' . $cache_subdir . '/' . $hash . '.' . $hash_ext;
    if( file_exists($cache_file) && ($time - filemtime($cache_file) < $this->ttl) )
    {
    $file = fopen( $cache_file, 'r' );
    if( $file )
    {
    $data = fread( $file, filesize($cache_file) );
    fclose( $file );
    return unserialize( $data );
    }
    else
    return false;
    }
    else
    return false;

    }

    //-----------------------------------------------------------------------------------------
    function write( $data )
    {
    if( !$this->enabled )
    return true;

    $name = $_SERVER['REQUEST_URI'];
    $ext = $_SESSION['user'];
    $hash = sha1($name);
    $hash_ext = sha1($ext);
    $cache_dir = $this->cache_root . '/' . substr( $hash, 0, 5 );
    $cache_subdir = $cache_dir . '/' . substr( $hash, 5, 5 );
    if( !is_dir($cache_dir) )
    mkdir( $cache_dir, 0775 );
    if( !is_dir($cache_subdir) )
    mkdir( $cache_subdir, 0775 );
    $file = fopen( $cache_subdir.'/'.$hash.'.'.$hash_ext, 'w' );
    if( $file )
    {
    $res = fwrite( $file, serialize($data) );
    fclose( $file );
    return $res;
    }
    return false;
    }

    //-----------------------------------------------------------------------------------------
    function delete( $what, $id, $title )
    {
    switch( $what )
    {
    case 'game':
    $name = GameURL( $id, $title );
    $hash = sha1($name);
    $cache_dir = (substr($this->cache_root,-1) == '/') ? substr( $this->cache_root, 0, -1 ) : $this->cache_root;
    $cache_dir .= '/' . substr( $hash, 0, 5 ) . '/' . substr( $hash, 5, 5 );
    remove_directory( $cache_dir );
    break;
    case 'cat':
    $name = CategoryURL( $title );
    $hash = sha1($name);
    $cache_dir = (substr($this->cache_root,-1) == '/') ? substr( $this->cache_root, 0, -1 ) : $this->cache_root;
    $cache_dir .= '/' . substr( $hash, 0, 5 ) . '/' . substr( $hash, 5, 5 );
    remove_directory( $cache_dir );
    case 'home':
    $name = $GLOBALS['cSite']['sSiteRoot'];
    $hash = sha1($name);
    $cache_dir = (substr($this->cache_root,-1) == '/') ? substr( $this->cache_root, 0, -1 ) : $this->cache_root;
    $cache_dir .= '/' . substr( $hash, 0, 5 ) . '/' . substr( $hash, 5, 5 );
    remove_directory( $cache_dir );
    break;
    case 'page':
    $name = $GLOBALS['cSite']['sSiteRoot'] . 'docs/' . $id;
    $hash = sha1($name);
    $cache_dir = (substr($this->cache_root,-1) == '/') ? substr( $this->cache_root, 0, -1 ) : $this->cache_root;
    $cache_dir .= '/' . substr( $hash, 0, 5 ) . '/' . substr( $hash, 5, 5 );
    remove_directory( $cache_dir );
    break;
    default:
    break;
    }
    }


    //-----------------------------------------------------------------------------------------
    function clear_cache()
    {
    // empty the cache dir
    remove_directory( $this->cache_root, TRUE );
    }


    }//class


    ?>
     
    Last edited: Mar 14, 2012
    Imozeb, Mar 14, 2012 IP
  9. ROOFIS

    ROOFIS Well-Known Member

    Messages:
    1,234
    Likes Received:
    30
    Best Answers:
    5
    Trophy Points:
    120
    #9
    Looks like there are a lot of restricted pathways on 000webhost and as others have pointed out looks like they treat them as external calls. What about placing the class and it's call back on the one page? since then there would be no "external" calls, might work but maybe a heavy slow page to load.
     
    ROOFIS, Mar 14, 2012 IP
  10. Imozeb

    Imozeb Peon

    Messages:
    666
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Nevermind I got it. Thanks everyone.
     
    Imozeb, Mar 14, 2012 IP
  11. ranaji

    ranaji Peon

    Messages:
    15
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #11
    try it to empty cache and these are due to not well configuration of apache server. so configure it well then try it.
     
    ranaji, Mar 15, 2012 IP
  12. samirj09

    samirj09 Well-Known Member

    Messages:
    335
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    125
    #12
    Dang thats a lot of disable_functions.

    system, show_source, exec, shell_exec, proc_open, passthru, set_time_limit, ini_restore, mysql_list_dbs, ini_alter, dl, pfsockopen, openlog, syslog, symlink, link, chgrp, leak, popen, escapeshellcmd, apache_child_terminate, apache_get_modules, apache_get_version, apache_getenv, apache_note, apache_setenv, virtual, mb_send_mai
     
    samirj09, Mar 15, 2012 IP