www.webdeveloper.com
Results 1 to 9 of 9

Thread: PHP Fatal error: Call to undefined function avantfax_session() in /var/www/html/fax

  1. #1
    Join Date
    Nov 2013
    Location
    Phoenix, AZ
    Posts
    5

    PHP Fatal error: Call to undefined function avantfax_session() in /var/www/html/fax

    I am having an issue with a fresh install of CentOS 6 via a FreePBX 2.1x ISO. PHP 5.3.3

    My FreePBX gui works perfectly. I have installed Hylafax and Avantfax. The Avantfax gui gives a login, but then a white screen. I eliminated a lot of errors by following a suggestion on another board: modify 1 line in classess.php like this:

    function __autoload($class_name) {
    if (file_exists('/var/www/html/fax/includes/'.$class_name . '.php')) require_once $class_name . '.php';
    }"

    But if I leave index.php alone, I get "PHP Fatal error: Call to undefined function avantfax_session() in /var/www/html/fax/index.php on line 15"

    If I put in the suggestion to add the line below in index.php

    set_include_path('.:/var/www/html/fax/includes/:/usr/share/php:/usr/share/pear');

    I get the same error saying it is on line 15.

    I'm quite new to PHP. Thanks for any input.

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,336
    Hard to say without even knowing what line 15 is, or what precedes it.

    However, looks to me like you may need the full path for the require:
    PHP Code:
    function __autoload($class_name) {
      if (
    file_exists('/var/www/html/fax/includes/'.$class_name '.php')) {
        require_once 
    '/var/www/html/fax/includes/'.$class_name '.php';
      }
      else {
        throw new 
    Exception("Could not load class '$class_name'");
      }

    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Nov 2013
    Location
    Phoenix, AZ
    Posts
    5
    Thanks for the response. Here is a paste of the first portion of my /var/www/html/fax/includes/classes.php after your suggestion:

    <?php
    /**
    * AvantFAX - "Web 2.0" HylaFAX management
    *
    * PHP 5 only
    *
    * @author David Mimms <david@avantfax.com>
    * @copyright 2005 - 2007 MENTALBARCODE Software, LLC
    * @copyright 2007 - 2008 iFAX Solutions, Inc.
    * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
    */

    function __autoload($class_name) {
    if (file_exists('/var/www/html/fax/includes/'.$class_name . '.php')) {
    require_once '/var/www/html/fax/includes/'.$class_name . '.php';
    }
    else {
    throw new Exception("Could not load class '$class_name'");
    }
    }
    /**
    * __autoload function
    *
    * @param string class_name

    And here is the first part of my /var/www/html/fax/index.php

    <?php
    /**
    * AvantFAX - "Web 2.0" HylaFAX management
    *
    * PHP 5 only
    *
    * @author David Mimms <david@avantfax.com>
    * @copyright 2005 - 2007 MENTALBARCODE Software, LLC
    * @copyright 2007 - 2008 iFAX Solutions, Inc.
    * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
    */

    set_include_path('.:/var/www/html/fax/includes/:/usr/share/php:/usr/share/pear');

    require_once 'includes/classes.php';

    avantfax_session();

    if (array_key_exists(USERSESSION, $_SESSION)) {
    if ($_SESSION[USERSESSION]->check_login()) {
    header("Location: inbox.php");
    exit;

    When I hit the webpage it is white and I get this error in /var/log/httpd/ssl_error_log

    [Mon Nov 11 21:53:39 2013] [error] [client <my.pub.lic.ip>] PHP Fatal error: Call to undefined function avantfax_session() in /var/www/html/fax/index.php on line 17

  4. #4
    Join Date
    Nov 2013
    Location
    Phoenix, AZ
    Posts
    5

    changed classes.php

    sorry for this lengthy reply. I looked at a classes.php on a box that works, but is running CentOS release 5.8 (Final) and PHP 5.3.10. rsynced that file to the CentOS6 box running PHP5.3.3

    Here is the contents of beginning of classes.php followed by the error log when I access the web page. I do get the login page on the Web, but when I enter my creds it gives me the white page again. Thanks.



    <?php
    /**
    * AvantFAX - "Web 2.0" HylaFAX management
    *
    * PHP 5 only
    *
    * @author David Mimms <david@avantfax.com>
    * @copyright 2005 - 2007 MENTALBARCODE Software, LLC
    * @copyright 2007 - 2008 iFAX Solutions, Inc.
    * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
    */

    require_once 'config.php';
    require_once 'htmlMimeMail5.php';
    require_once 'SQL.php';
    require_once 'htmlMimeMail5.php';
    require_once 'Smarty.php';
    require_once 'htmlMimeMail5.php';
    require_once 'PWAuth.php';
    require_once 'htmlMimeMail5.php';
    require_once 'PAMAuth.php';
    require_once 'htmlMimeMail5.php';
    require_once 'MDBO.php';
    require_once 'htmlMimeMail5.php';
    require_once 'MDBOData.php';
    require_once 'htmlMimeMail5.php';
    require_once 'MDBObject.php';
    require_once 'htmlMimeMail5.php';
    require_once 'Mailer.php';
    require_once 'htmlMimeMail5.php';
    require_once 'FormRules.php';
    require_once 'htmlMimeMail5.php';
    require_once 'FileUpload.php';
    require_once 'htmlMimeMail5.php';
    require_once 'FaxQueue.php';
    require_once 'htmlMimeMail5.php';
    require_once 'FaxPDFCategory.php';
    require_once 'htmlMimeMail5.php';
    require_once 'FaxPDFArchive.php';
    require_once 'htmlMimeMail5.php';
    require_once 'FaxModem.php';
    require_once 'htmlMimeMail5.php';
    require_once 'DynamicConfig.php';
    require_once 'htmlMimeMail5.php';
    require_once 'DistributionList.php';
    require_once 'htmlMimeMail5.php';
    require_once 'DIDRouting.php';
    require_once 'htmlMimeMail5.php';
    require_once 'Covers.php';
    require_once 'htmlMimeMail5.php';
    require_once 'BarcodeRouting.php';
    require_once 'htmlMimeMail5.php';
    require_once 'ArchiveOut.php';
    require_once 'htmlMimeMail5.php';
    require_once 'ArchiveIn.php';
    require_once 'htmlMimeMail5.php';
    require_once 'AFUserPasswords.php';
    require_once 'htmlMimeMail5.php';
    require_once 'AFUserAccount.php';
    require_once 'htmlMimeMail5.php';
    require_once 'AFAddressBook.php';


    /**
    * __autoload function
    *
    * @param string class_name
    */
    /** function __autoload
    require_once $class_name . '.php';
    }
    */

    /**
    * AFSmarty
    */
    class AFSmarty extends Smarty
    {

    [Tue Nov 12 00:06:06 2013] [error] [client my.pub.lic.ip] PHP Deprecated: Assigning the return value of new by reference is deprecated in /usr/share/pear/MDB2.php on line 390
    [Tue Nov 12 00:06:06 2013] [error] [client my.pub.lic.ip] PHP Deprecated: Assigning the return value of new by reference is deprecated in /usr/share/pear/MDB2.php on line 1885
    [Tue Nov 12 00:06:06 2013] [error] [client my.pub.lic.ip] PHP Deprecated: Assigning the return value of new by reference is deprecated in /usr/share/pear/MDB2.php on line 2572
    [Tue Nov 12 00:06:06 2013] [error] [client my.pub.lic.ip] PHP Deprecated: Assigning the return value of new by reference is deprecated in /usr/share/pear/MDB2.php on line 2595
    [Tue Nov 12 00:06:06 2013] [error] [client my.pub.lic.ip] PHP Deprecated: Assigning the return value of new by reference is deprecated in /usr/share/pear/MDB2.php on line 2940
    [Tue Nov 12 00:06:06 2013] [error] [client my.pub.lic.ip] PHP Deprecated: Assigning the return value of new by reference is deprecated in /usr/share/pear/MDB2/Driver/mysql.php on line 924
    [Tue Nov 12 00:06:06 2013] [error] [client my.pub.lic.ip] PHP Deprecated: Assigning the return value of new by reference is deprecated in /usr/share/pear/MDB2/Driver/mysql.php on line 1190
    [Tue Nov 12 00:06:06 2013] [error] [client my.pub.lic.ip] PHP Warning: The magic method __unset() must have public visibility and cannot be static in /var/www/html/fax/includes/FormRules.php on line 461
    [Tue Nov 12 00:06:06 2013] [error] [client my.pub.lic.ip] PHP Warning: The magic method __isset() must have public visibility and cannot be static in /var/www/html/fax/includes/FormRules.php on line 472
    [Tue Nov 12 00:06:06 2013] [error] [client my.pub.lic.ip] PHP Warning: The magic method __get() must have public visibility and cannot be static in /var/www/html/fax/includes/FormRules.php on line 486
    [Tue Nov 12 00:06:06 2013] [error] [client my.pub.lic.ip] PHP Warning: The magic method __set() must have public visibility and cannot be static in /var/www/html/fax/includes/FormRules.php on line 507
    [Tue Nov 12 00:06:06 2013] [error] [client my.pub.lic.ip] PHP Warning: The magic method __unset() must have public visibility and cannot be static in /var/www/html/fax/includes/AFUserAccount.php on line 754
    [Tue Nov 12 00:06:06 2013] [error] [client my.pub.lic.ip] PHP Warning: The magic method __isset() must have public visibility and cannot be static in /var/www/html/fax/includes/AFUserAccount.php on line 767
    [Tue Nov 12 00:06:06 2013] [error] [client my.pub.lic.ip] PHP Warning: The magic method __get() must have public visibility and cannot be static in /var/www/html/fax/includes/AFUserAccount.php on line 783
    [Tue Nov 12 00:06:06 2013] [error] [client my.pub.lic.ip] PHP Warning: The magic method __set() must have public visibility and cannot be static in /var/www/html/fax/includes/AFUserAccount.php on line 800












    QUOTE=NogDog;1296281]Hard to say without even knowing what line 15 is, or what precedes it.

    However, looks to me like you may need the full path for the require:
    PHP Code:
    function __autoload($class_name) {
      if (
    file_exists('/var/www/html/fax/includes/'.$class_name '.php')) {
        require_once 
    '/var/www/html/fax/includes/'.$class_name '.php';
      }
      else {
        throw new 
    Exception("Could not load class '$class_name'");
      }

    [/QUOTE]

  5. #5
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,336
    I just realized that the autoload stuff is kind of a red herring here. The original error is about an undefined function, not an undefined class, and __autoload() only deals with loading class definitions. You need to find out where that function is defined, make sure that definition file gets loaded -- and don't forget to make sure there aren't any simple spelling mistakes (remembering that function names are case-sensitive).

    As far as those warnings about assigning by reference and public versus static for __isset(), that's more an indication of old and/or poorly written code. The "deprecated" warnings are not critical for now, though in some future version of PHP might pose a problem. Since they are coming from a PEAR library, you might want to make sure you have the latest version, though many of them have not been updated, so you may be stuck with either changing them if you want, or just turning off deprecated notices entirely if it's a problem having all of them in your error logs. To fix, just look for this pattern, and delete the "&":
    PHP Code:
    $foo =& new SomeClass(); 
    Presumably the other warning is for classes with an __isset() method declared like this:
    PHP Code:
    static __isset($something
    ...which should instead be:
    PHP Code:
    public __isset($something
    PS: If you use this forum's [php]...[/php] tags around your PHP code, it will be much easier to read.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  6. #6
    Join Date
    Nov 2013
    Location
    Phoenix, AZ
    Posts
    5
    Sorry for the delay in responding to your post. After reading your suggestions I decided to go back to the original classes.php and index.php. I noticed a mysql error at the end of my log. Did some checking and found out that my tables were not set up. Went back to the install directions and ran some scripts from the source directory and all is working now. Thanks for sticking with me. I still get the errors below. Can you advise me on them now that my Web gui is working properly? I get these errors for every page I navigate to in the gui. Thanks.

    [Mon Nov 18 15:50:59 2013] [error] [client <my.src.public.ip>] PHP Deprecated: Assigning the return value of new by reference is deprecated in /usr/share/pear/MDB2.php on line 390, referer: https://<my.pub.lic.ip>/fax/admin/admin.php
    [Mon Nov 18 15:50:59 2013] [error] [client <my.src.public.ip>] PHP Deprecated: Assigning the return value of new by reference is deprecated in /usr/share/pear/MDB2.php on line 1885, referer: https://<my.pub.lic.ip>/fax/admin/admin.php
    [Mon Nov 18 15:50:59 2013] [error] [client <my.src.public.ip>] PHP Deprecated: Assigning the return value of new by reference is deprecated in /usr/share/pear/MDB2.php on line 2572, referer: https://<my.pub.lic.ip>/fax/admin/admin.php
    [Mon Nov 18 15:50:59 2013] [error] [client <my.src.public.ip>] PHP Deprecated: Assigning the return value of new by reference is deprecated in /usr/share/pear/MDB2.php on line 2595, referer: https://<my.pub.lic.ip>/fax/admin/admin.php
    [Mon Nov 18 15:50:59 2013] [error] [client <my.src.public.ip>] PHP Deprecated: Assigning the return value of new by reference is deprecated in /usr/share/pear/MDB2.php on line 2940, referer: https://<my.pub.lic.ip>/fax/admin/admin.php
    [Mon Nov 18 15:50:59 2013] [error] [client <my.src.public.ip>] PHP Deprecated: Assigning the return value of new by reference is deprecated in /usr/share/pear/MDB2/Driver/mysql.php on line 924, referer: https://<my.pub.lic.ip>/fax/admin/admin.php
    [Mon Nov 18 15:50:59 2013] [error] [client <my.src.public.ip>] PHP Deprecated: Assigning the return value of new by reference is deprecated in /usr/share/pear/MDB2/Driver/mysql.php on line 1190, referer: https://<my.pub.lic.ip>/fax/admin/admin.php
    [Mon Nov 18 15:50:59 2013] [error] [client <my.src.public.ip>] PHP Warning: The magic method __unset() must have public visibility and cannot be static in /var/www/html/fax/includes/AFUserAccount.php on line 754, referer: https://<my.pub.lic.ip>/fax/admin/admin.php
    [Mon Nov 18 15:50:59 2013] [error] [client <my.src.public.ip>] PHP Warning: The magic method __isset() must have public visibility and cannot be static in /var/www/html/fax/includes/AFUserAccount.php on line 767, referer: https://<my.pub.lic.ip>/fax/admin/admin.php
    [Mon Nov 18 15:50:59 2013] [error] [client <my.src.public.ip>] PHP Warning: The magic method __get() must have public visibility and cannot be static in /var/www/html/fax/includes/AFUserAccount.php on line 783, referer: https://<my.pub.lic.ip>/fax/admin/admin.php
    [Mon Nov 18 15:50:59 2013] [error] [client <my.src.public.ip>] PHP Warning: The magic method __set() must have public visibility and cannot be static in /var/www/html/fax/includes/AFUserAccount.php on line 800, referer: https://<my.pub.lic.ip>/fax/admin/admin.php
    [Mon Nov 18 15:50:59 2013] [error] [client <my.src.public.ip>] PHP Warning: strftime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Denver' for 'MST/-7.0/no DST' instead in /var/www/html/fax/includes/Smarty/Smarty_Compiler.class.php on line 400, referer: https://<my.pub.lic.ip>/fax/admin/admin.php

  7. #7
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,336
    Each error message tells you which file the error (or notice) was in, and what line number. For the "deprecated" warnings, you don't have to fix it now, but there's no guarantee that it won't become a fatal error in some future release of PHP. I mentioned in an earlier reply what to look for, and to fix it simply remove the offending "&" character next to the "=" sign.

    The "magic method" warning is more severe, and should be fixed. It's simply a case of changing the method declaration to be "public" instead of "static".

    This one:
    [Mon Nov 18 15:50:59 2013] [error] [client <my.src.public.ip>] PHP Warning: strftime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Denver' for 'MST/-7.0/no DST' instead in /var/www/html/fax/includes/Smarty/Smarty_Compiler.class.php on line 400, referer: https://<my.pub.lic.ip>/fax/admin/admin.php
    can be fixed by sticking something like this at the beginning of your config file:
    PHP Code:
    date_default_timezone_set('America/Denver'); 
    (assuming that's the default timezone you want to use?)
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  8. #8
    Join Date
    Nov 2013
    Location
    Phoenix, AZ
    Posts
    5

    The "magic method" warning is more severe, and should be fixed.

    Thanks for the reply. You say "It's simply a case of changing the method declaration to be "public" instead of "static"."

    I'm very new to PHP and don't want to botch this. Below is a paste from my /var/www/html/fax/includes/AFUserAccount.php with the lines from the error log added in quotes. Should I change something on those lines, or at the top of the file? I see where the functions are defined? at the top of AFUserAccount.php under

    CLASS: AFUserAccount
    METHODS:
    public function __construct()
    public function init_db()
    public function create(array $details)
    public function list_accounts()
    ...
    ...
    private function __unset($varname)
    private function __isset($varname)
    private function __get($varname)
    private function __set($varname, $value)
    private function load_vals(array $data)

    Here are two of the offending examples:
    /**
    * PRIVATE FUNCTIONS
    */

    /**
    * __unset
    *
    * @param string varname
    * @return void
    * @access private
    */
    "line 754" private function __unset($varname) {
    if (is_array($this->dbdata)) {
    $this->unsetRule($this->dbdata[$varname]);
    }
    }

    /**
    * __isset
    *
    * @param string varname
    * @return bool
    * @access private
    */
    "line 767" private function __isset($varname) {
    if (is_array($this->dbdata)) {
    if (array_key_exists($varname, $this->dbdata)) {


    Thanks,

    Cory

  9. #9
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,336
    So these reserved "magic method" names must be public:
    PHP Code:
    private function __unset($varname)
    private function 
    __isset($varname)
    private function 
    __get($varname)
    private function 
    __set($varname$value
    ...so they need to be changed to:
    PHP Code:
    public function __unset($varname)
    public function 
    __isset($varname)
    public function 
    __get($varname)
    public function 
    __set($varname$value
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles