Results 1 to 10 of 10

Thread: Admin area reporting PHP error after adding custom hooks and add-ons

  1. #1
    Join Date
    Apr 2011
    Posts
    14

    Default Admin area reporting PHP error after adding custom hooks and add-ons

    Hi,

    I am suddenly unable to log into the admin area. The rest of the site works fine - I can view everything, including the listings, but the admin area reports a Server Error. I've been playing around with add-ons and hooks, but didn't do anything to my knowledge that could have caused this.

    I assume it has something to do with the database, since even removing all code in my hooks and add-ons has no effect.

    What could be causing the problem? Specifically, are there any rows/tables I can delete to get things going again?

  2. #2
    the_sandking's Avatar
    the_sandking is offline hadron remnant - Moderation Fachmann
    Join Date
    Apr 2003
    Location
    Nullspace
    Posts
    5,289

    Default Re: Admin area reporting PHP error after adding custom hooks and add-ons

    Your thread title says you have a PHP error, but in your thread you say it's a server error. Which is it?

    Server errors are logged and timestamped for the exact time you caused it to happen. Examine your server error logs for the time it failed and you will likely obtain the exact cause.

    If it's really a PHP error, we'd need to see the error to make any sort of recommendation.

    If you are playing around, undo whatever it is you have done and things will probably start working again. Return the hooks folder and contents to however they were exactly before you started, and remove any add-ons completely from /addons/
    "Much of what looks like rudeness in hacker circles is not intended to give offense. Rather, it's the product of the direct, cut-through-the-BS communications style that is natural to people who are more concerned about solving problems than making others feel warm and fuzzy."

    "We gotta' go to the crappy town where I'm a hero!"
    -Hoban 'Wash' Washburne 2485-2519


    "When you’re born you get a ticket to the freak show. When you’re born in America, you get a front-row seat.."
    -George Carlin 1937-2008

    New to Open-Realty® and need help? Check the:
    -OR DOCUMENTATION -

    Important: Read this at least once in your lifetime
    How To Ask Questions The Smart Way

  3. #3
    Join Date
    Apr 2011
    Posts
    14

    Default Re: Admin area reporting PHP error after adding custom hooks and add-ons

    The error page says "Server error." - but I don't see any error in the logs. Or at least, I don't know where to look - there's no php error file in /var/logs/ - where else could it be? Anyway, here is the code fragment that is causing the error (in bold), which is called inside a hook file:

    Code:
    class flatsearch_hook 
    {
        function after_listing_change($listingID) 
        {
            global $config, $conn, $lang;
            $listings_sql = 'SELECT * FROM ' . $config["table_prefix_no_lang"] . $config[lang] . '_listingsdb WHERE listingsdb_id = ' . $listingID;
            $listings_rs = $conn->Execute($listings_sql);
            if (!$listings_rs) log_error($listings_sql);    
            
            // Build code
            
            $url = 'http://localhost:8000/listings/ajax/submit/';
            $ch = curl_init($url);
            $token = '2011-04-26 20:42:34.804754';
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, 'token=' . urlencode($token) . '&price=$price');
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
            curl_exec($ch);
            curl_close($ch);
        }
    }
    I don't see what's wrong with this, but it's causing the entire admin panel to crash. Removing the code snippet, or even the entire hook file, has no effect - the admin panel still crashes. It can't really be a server error (I think), since it only happens when this code snippet is added, and doesn't go away when it is taken away. Something inside OR must have changed. Any ideas?

  4. #4
    Join Date
    Apr 2011
    Posts
    14

    Default Re: Admin area reporting PHP error after adding custom hooks and add-ons

    I've now also confirmed that it can't even be something with the database: Dropping the entire database, and reintstalling OR does not remove the problem - only complete replacement of the OR folder fixes the problem. What files does OR create that could break the admin panel?

  5. #5
    the_sandking's Avatar
    the_sandking is offline hadron remnant - Moderation Fachmann
    Join Date
    Apr 2003
    Location
    Nullspace
    Posts
    5,289

    Default Re: Admin area reporting PHP error after adding custom hooks and add-ons

    You need to look in your server error logs. The server error logs will be located wherever whoever setup your server configured them to be located.

    OR only creates the common.php file upon install.

    By replacing the entire OR folder you have undone whatever it was you did. It was doubtful it was ever anything to do with your DB, you probably still had add-on code beneath /addons/ which was everwritten when you replaced everything.
    "Much of what looks like rudeness in hacker circles is not intended to give offense. Rather, it's the product of the direct, cut-through-the-BS communications style that is natural to people who are more concerned about solving problems than making others feel warm and fuzzy."

    "We gotta' go to the crappy town where I'm a hero!"
    -Hoban 'Wash' Washburne 2485-2519


    "When you’re born you get a ticket to the freak show. When you’re born in America, you get a front-row seat.."
    -George Carlin 1937-2008

    New to Open-Realty® and need help? Check the:
    -OR DOCUMENTATION -

    Important: Read this at least once in your lifetime
    How To Ask Questions The Smart Way

  6. #6
    Join Date
    Apr 2011
    Posts
    14

    Default Re: Admin area reporting PHP error after adding custom hooks and add-ons

    That's not the case. Removing ALL files in the add-ons and hook folders makes absolutely no difference. Apparently, if there is any error in the code at all, OR continues to report the error after the first run, even if the code is fixed or completely removed. This makes debugging ridiculously difficult, so, is there something I'm missing?

  7. #7
    Join Date
    Apr 2011
    Posts
    14

    Default Re: Admin area reporting PHP error after adding custom hooks and add-ons

    Also, I know this is a PHP question, but where are the logs stored by default? I installed all the software myself, and never specifically set any values as to where the logs should be stored.

  8. #8
    the_sandking's Avatar
    the_sandking is offline hadron remnant - Moderation Fachmann
    Join Date
    Apr 2003
    Location
    Nullspace
    Posts
    5,289

    Default Re: Admin area reporting PHP error after adding custom hooks and add-ons

    Quote Originally Posted by Herman Schaaf View Post
    Apparently, if there is any error in the code at all, OR continues to report the error after the first run, even if the code is fixed or completely removed.
    That's not really possible, unless of course you can explain how exactly this error would be retained by the server when the code is no longer present. It's not like server-side code gets cached by your browser like CSS, images or javascript. OR does not store errors or failures in it's cookies either.

    Server error logs are your friend, you need to find out where PHP is reporting errors, this is true especially if you are going to be developing in PHP or any other application that runs through APACHE. I keep my error logs open or handy almost all the time I am working on code.

    There is no default location for the error logs, it's determined by whoever compiled & setup the webserver.
    "Much of what looks like rudeness in hacker circles is not intended to give offense. Rather, it's the product of the direct, cut-through-the-BS communications style that is natural to people who are more concerned about solving problems than making others feel warm and fuzzy."

    "We gotta' go to the crappy town where I'm a hero!"
    -Hoban 'Wash' Washburne 2485-2519


    "When you’re born you get a ticket to the freak show. When you’re born in America, you get a front-row seat.."
    -George Carlin 1937-2008

    New to Open-Realty® and need help? Check the:
    -OR DOCUMENTATION -

    Important: Read this at least once in your lifetime
    How To Ask Questions The Smart Way

  9. #9
    Join Date
    Apr 2011
    Posts
    14

    Default Re: Admin area reporting PHP error after adding custom hooks and add-ons

    Ok, so I found the root of the error: The hooks folder interprets the hidden linux backup file of a hook (_hook.php~) as a proper hook file (which it shouldn't), and executes the code. Since this code contains a class definition, and the class is already defined in another file, the admin panel crashes.

  10. #10
    the_sandking's Avatar
    the_sandking is offline hadron remnant - Moderation Fachmann
    Join Date
    Apr 2003
    Location
    Nullspace
    Posts
    5,289

    Default Re: Admin area reporting PHP error after adding custom hooks and add-ons

    O.K. so you basically didn't restore everything to how it was before you started playing around.
    "Much of what looks like rudeness in hacker circles is not intended to give offense. Rather, it's the product of the direct, cut-through-the-BS communications style that is natural to people who are more concerned about solving problems than making others feel warm and fuzzy."

    "We gotta' go to the crappy town where I'm a hero!"
    -Hoban 'Wash' Washburne 2485-2519


    "When you’re born you get a ticket to the freak show. When you’re born in America, you get a front-row seat.."
    -George Carlin 1937-2008

    New to Open-Realty® and need help? Check the:
    -OR DOCUMENTATION -

    Important: Read this at least once in your lifetime
    How To Ask Questions The Smart Way

Similar Threads

  1. 500.shtml error in admin area
    By Dunover in forum General Help (CLOSED)
    Replies: 4
    Last Post: 03-02-2010, 02:27 PM
  2. Accessing custom page within admin area
    By antonitus in forum General Help (CLOSED)
    Replies: 10
    Last Post: 12-03-2007, 06:36 PM
  3. Custom Admin Area?
    By gman in forum General Discussion
    Replies: 3
    Last Post: 03-12-2007, 05:38 PM
  4. adding links to the agent admin area
    By cellularguy in forum General Help (CLOSED)
    Replies: 5
    Last Post: 06-15-2005, 10:37 PM

Bookmarks

Posting Permissions

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