Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7694515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:20:17+00:00 2026-05-31T21:20:17+00:00

I’ve inherited a site from a previous (no longer available for help) developer and

  • 0

I’ve inherited a site from a previous (no longer available for help) developer and I’m not much of a PHP coder to begin with so, bear with me.

I keep getting an error that some variables are undefined and the CMS Admin toolbar keeps showing up at the top of the page even though I’m not logged in.

Important Note This only happens in my local development environment.

The error:

Notice: Undefined variable: buttons in /Users/shortname/Sites/sitename.com/public_html/admin/editable.class.php on line 275

Edit Here’s the complete file:

Pastebin of editable.class.php

In my page, I’ve got an include

<?php
    include_once 'admin/editable.class.php';

    $page = new page(6, 2, 0);
    echo $page->get();
?>

It’s job is to grab all the page elements from the DB and throw it on the page.

The include appears later in the page as well (in the footer)

<?
include_once "admin/editable.class.php";
$login = new dynamic;

if($login->isAdmin())
{
    echo '
    <div id="adminBar">
        <div>
            <h3>Admin Menu</h3> <span class="editable">Editable Pages: <a href="/company/media.php">In The Media</a> | <a href="/company/faq_about.php">FAQ</a> | <a href="/company/tradeshows.php">Tradeshows</a></span> <a class="logout" href="/admin">Logout</a>
        </div>
    </div>
    ';
}
?>

Which I assume is what shows the CMS info bar and buttons if you’re an authenticated user. The trouble is, I can’t authenticate and I can’t get the warnings to go away. Here’s the authentication functions in editable.class.php:

function isAdmin()
    {
        if (isset($_COOKIE["admin"]) && $_COOKIE["admin"] === sha1("username".$this->salt.$this->users["username"]))
        {
            $this->admin = true;

            return true;
        }
        else
        {
            $this->admin = false;

            return false;
        }
    }

    function login()
    {
        if($this->isAdmin())
        {
            return true;
        }

        if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($this->users[$_SERVER['PHP_AUTH_USER']]) || $this->users[$_SERVER['PHP_AUTH_USER']] !== $_SERVER['PHP_AUTH_PW']) 
        {
            header('WWW-Authenticate: Basic realm="Administration"');
            header('HTTP/1.0 401 Unauthorized');
            echo 'Authorization Required';
            exit;
        }
        else
        {           
            setcookie("admin", sha1("username".$this->salt.$this->users["username"]), 0, "/", ".sitename.com");
            $this->admin = true;

            return true;
        }
    }

    function logout()
    {
        header('HTTP/1.0 401 Unauthorized');
        setcookie("username", "", time() - 1, "/", ".sitename.com");
    }

I tried adding <?php setcookie("username", "", time() - 1, "/", ".sitename.com"); ?> to see if I could clear out the cookie data and remove the admin tools but, that didn’t work either. What am I missing on my local development environment that would cause these errors?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T21:20:18+00:00Added an answer on May 31, 2026 at 9:20 pm

    It is giving you a notice because when you define the buttons variable, it is out of scope. So, just change your code from:

    if($this->admin)
    {
        $buttons =  $this->editButtons;
    }
    else
    {
        $butons = "";
    }
    

    to this:

    $buttons = '';
    if($this->admin)
        $buttons = $this->editButtons;
    

    This is shorthand code, you can add the brackets if you like.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.