Can't access Admin after update

Ask the community for help and support.
jimpike
Posts: 6
Joined: Thu Mar 25, 2021 4:47 am
Has thanked: 2 times
Been thanked: 1 time

Can't access Admin after update

Post by jimpike »

I used the add-on for the updater tool and everything seemed to go fine. But now when I try to log into the admin section, after entering my username and password, I get an error screen saying "The requested URL was not found on this server." In the address bar, it's pointing to /admin/1

I would provide the other info needed, live version and such, but as I can't access the admin area, I'm not able to get this information. But I believe the version it updated to is 1.0.8.2

Any ideas as how I can get back into it?
User avatar
zipurman
PhoenixCart Developer
PhoenixCart Developer
Posts: 179
Joined: Tue Oct 13, 2020 5:20 pm
Location: Canada (CST)
Has thanked: 30 times
Been thanked: 63 times

Re: Can't access Admin after update

Post by zipurman »

If you remove the /admin/1 and change to /admin/ does it forward again to /admin/1 ? If so, have a look at your /.htaccess and /admin/.htaccess files to see if there are any redirects in there.
zipurman
aka Preston Lord
-----------
Happy to help where I can ;)

https://phoenixaddons.com
https://www.youtube.com/zipurman/ ** PHOENIX HOW-TO VIDEOS **
Image
jimpike
Posts: 6
Joined: Thu Mar 25, 2021 4:47 am
Has thanked: 2 times
Been thanked: 1 time

Re: Can't access Admin after update

Post by jimpike »

I've tried taking out the 1, and it goes back to asking me to log in. When I log in, it goes right back to the /1
Main htaccess:

Code: Select all

<IfModule mod_headers.c>
  Header unset ETag
</IfModule>
FileETag None

## EXPIRES CACHING ##
## https://gtmetrix.com/leverage-browser-caching.html ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
ExpiresDefault "access plus 2 days"
</IfModule>
Admin htaccess:

Code: Select all

AuthType Basic
AuthName "OSCOM CE Phoenix Administration Tool"
AuthUserFile /home/allys/public_html/admin/.htpasswd_oscommerce
Require valid-user
Contents of .htpasswd_oscommerce is just the two admins I've added, and the passwords in hex.
User avatar
zipurman
PhoenixCart Developer
PhoenixCart Developer
Posts: 179
Joined: Tue Oct 13, 2020 5:20 pm
Location: Canada (CST)
Has thanked: 30 times
Been thanked: 63 times

Re: Can't access Admin after update

Post by zipurman »

Also check your admin/includes/configure.php to see what paths are in there.

DO NOT POST any user/pass info in your reply.
zipurman
aka Preston Lord
-----------
Happy to help where I can ;)

https://phoenixaddons.com
https://www.youtube.com/zipurman/ ** PHOENIX HOW-TO VIDEOS **
Image
jimpike
Posts: 6
Joined: Thu Mar 25, 2021 4:47 am
Has thanked: 2 times
Been thanked: 1 time

Re: Can't access Admin after update

Post by jimpike »

Admin/includes/configure.php

Code: Select all

<?php
// set the level of error reporting
  error_reporting(E_ALL);

  const HTTP_SERVER = 'https://allysuniqueworld.com';
  const COOKIE_OPTIONS = [
    'lifetime' => 0,
    'domain' => 'allysuniqueworld.com',
    'path' => '/admin',
    'samesite' => 'Lax',
    'secure' => true,
  ];
  const DIR_WS_ADMIN = '/admin/';

  const DIR_FS_DOCUMENT_ROOT = '/home/allys/public_html/';
  const DIR_FS_ADMIN = '/home/allys/public_html/admin/';
  const DIR_FS_BACKUP = DIR_FS_ADMIN . 'backups/';

  const HTTP_CATALOG_SERVER = 'https://allysuniqueworld.com';
  const DIR_WS_CATALOG = '/';
  const DIR_FS_CATALOG = '/home/allys/public_html/';

  date_default_timezone_set('America/New_York');
Main includes/configure.php

Code: Select all

<?php
// set the level of error reporting
  error_reporting(E_ALL);

  const HTTP_SERVER = 'https://allysuniqueworld.com';
  const COOKIE_OPTIONS = [
    'lifetime' => 0,
    'domain' => 'allysuniqueworld.com',
    'path' => '/',
    'samesite' => 'Lax',
    'secure' => true,
  ];
  const DIR_WS_CATALOG = '/';

  const DIR_FS_CATALOG = '/home/allys/public_html/';

  date_default_timezone_set('America/New_York');
I'm not seeing where this "1" is coming from.
ecartz
Lead Developer
Lead Developer
Posts: 1022
Joined: Tue Nov 05, 2019 6:02 pm
Has thanked: 4 times
Been thanked: 93 times

Re: Can't access Admin after update

Post by ecartz »

Error document maybe?

Does /home/allys/public_html/admin/.htpasswd_oscommerce exist?
jimpike
Posts: 6
Joined: Thu Mar 25, 2021 4:47 am
Has thanked: 2 times
Been thanked: 1 time

Re: Can't access Admin after update

Post by jimpike »

Contents of .htpasswd_oscommerce is just the two admins I've added, and the passwords in hex.
Error log: (Hopefully this helps)

Code: Select all

[Tue May 04 13:44:19.355051 2021] [fcgid:warn] [pid 2243200] [client *.*.*.*:50862] mod_fcgid: stderr: PHP Notice:  Undefined index: db in /home/allys/public_html/includes/system/versioned/1.0.8.1/hooks.php on line 65
[Tue May 04 13:44:19.355090 2021] [fcgid:warn] [pid 2243200] [client *.*.*.*:50862] mod_fcgid: stderr: PHP Fatal error:  Uncaught Error: Call to a member function query() on null in /home/allys/public_html/includes/system/versioned/1.0.8.1/hooks.php:65
[Tue May 04 13:44:19.355096 2021] [fcgid:warn] [pid 2243200] [client *.*.*.*:50862] mod_fcgid: stderr: Stack trace:
[Tue May 04 13:44:19.355099 2021] [fcgid:warn] [pid 2243200] [client *.*.*.*:50862] mod_fcgid: stderr: #0 /home/allys/public_html/includes/system/versioned/1.0.8.1/hooks.php(121): hooks->load()
[Tue May 04 13:44:19.355102 2021] [fcgid:warn] [pid 2243200] [client *.*.*.*:50862] mod_fcgid: stderr: #1 /home/allys/public_html/includes/application_top.php(32): hooks->register()
[Tue May 04 13:44:19.355106 2021] [fcgid:warn] [pid 2243200] [client *.*.*.*:50862] mod_fcgid: stderr: #2 /home/allys/public_html/index.php(13): require('/home/allys/pub...')
[Tue May 04 13:44:19.355109 2021] [fcgid:warn] [pid 2243200] [client *.*.*.*:50862] mod_fcgid: stderr: #3 {main}
[Tue May 04 13:44:19.355112 2021] [fcgid:warn] [pid 2243200] [client *.*.*.*:50862] mod_fcgid: stderr:   thrown in /home/allys/public_html/includes/system/versioned/1.0.8.1/hooks.php on line 65
[Tue May 04 13:44:22.122677 2021] [fcgid:warn] [pid 2243146] [client *.*.*.*:50865] mod_fcgid: stderr: PHP Notice:  Undefined index: db in /home/allys/public_html/includes/system/versioned/1.0.8.1/hooks.php on line 65
[Tue May 04 13:44:22.122704 2021] [fcgid:warn] [pid 2243146] [client *.*.*.*:50865] mod_fcgid: stderr: PHP Fatal error:  Uncaught Error: Call to a member function query() on null in /home/allys/public_html/includes/system/versioned/1.0.8.1/hooks.php:65
[Tue May 04 13:44:22.122708 2021] [fcgid:warn] [pid 2243146] [client *.*.*.*:50865] mod_fcgid: stderr: Stack trace:
[Tue May 04 13:44:22.122712 2021] [fcgid:warn] [pid 2243146] [client *.*.*.*:50865] mod_fcgid: stderr: #0 /home/allys/public_html/includes/system/versioned/1.0.8.1/hooks.php(121): hooks->load()
[Tue May 04 13:44:22.122715 2021] [fcgid:warn] [pid 2243146] [client *.*.*.*:50865] mod_fcgid: stderr: #1 /home/allys/public_html/admin/includes/application_top.php(33): hooks->register()
[Tue May 04 13:44:22.122719 2021] [fcgid:warn] [pid 2243146] [client *.*.*.*:50865] mod_fcgid: stderr: #2 /home/allys/public_html/admin/index.php(13): require('/home/allys/pub...')
[Tue May 04 13:44:22.122722 2021] [fcgid:warn] [pid 2243146] [client *.*.*.*:50865] mod_fcgid: stderr: #3 {main}
[Tue May 04 13:44:22.122725 2021] [fcgid:warn] [pid 2243146] [client *.*.*.*:50865] mod_fcgid: stderr:   thrown in /home/allys/public_html/includes/system/versioned/1.0.8.1/hooks.php on line 65
I haven't altered any files, but as I said, I did use the upgrader.
Here is the hook.php:

Code: Select all

<?php
/*
  $Id$

  CE Phoenix, E-Commerce made Easy
  https://phoenixcart.org

  Copyright (c) 2021 Phoenix Cart

  Released under the GNU General Public License
*/

  class hooks {

    protected $_site;
    protected $_hooks = [];
    const PREFIX = 'listen_';
    protected $prefix_length;
    protected $pipelines = [];
    protected $page;
    protected $hook_directories = [];

    public function __construct($site) {
      $this->_site = basename($site);
      $this->prefix_length = strlen(self::PREFIX);
      $this->add_directory(DIR_FS_CATALOG . 'includes/hooks/');
    }

    public function add_directory($directory) {
      $this->hook_directories[] = $directory . $this->_site . '/';
    }

    protected function sort_hooks() {
      foreach ( $this->_hooks as &$actions ) {
        foreach ( $actions as &$codes ) {
          uksort($codes, 'strnatcmp');
        }
      }
    }

    protected function build_callback($class, $method) {
      if ('' === $class) {
        return $method;
      }

      if (isset($_SESSION[$class]) && is_callable([$_SESSION[$class], $method])) {
        return [$_SESSION[$class], $method];
      }

      if (!class_exists($class)) {
        return null;
      }

      if (is_callable([$class, $method])) {
        $m = new \ReflectionMethod($class, $method);
        if ($m->isStatic()) {
          return [$class, $method];
        }
      }

      return [Guarantor::ensure_global($class), $method];
    }

    protected function load($group) {
      $hooks_query = $GLOBALS['db']->query(sprintf(<<<'EOSQL'
SELECT hooks_action, hooks_code, hooks_class, hooks_method
 FROM hooks
 WHERE hooks_site = '%s' AND hooks_group = '%s'
EOSQL
, $GLOBALS['db']->escape($this->_site), $GLOBALS['db']->escape($group)));

      while ($hook = $hooks_query->fetch_assoc()) {
        $callback = $this->build_callback($hook['hooks_class'], $hook['hooks_method']);
        if (is_callable($callback)) {
          Guarantor::guarantee_all(
            $this->_hooks,
            $this->_site,
            $hook['hooks_action']
          )[$hook['hooks_code']] = $callback;
        }
      }

      $this->sort_hooks();
    }

    protected function register_directory($directory, &$files) {
      if ( file_exists($directory) && ( $dir = @dir($directory) ) ) {
        while ( $file = $dir->read() ) {
          if ( !is_dir("$directory/$file") ) {
            $files[] = $file;
          }
        }

        $dir->close();
      }
    }

    public function register($group) {
      $group = basename($group);

      $files = [];
      foreach ($this->hook_directories as $directory) {
        $this->register_directory("$directory$group", $files);
      }

      foreach ($files as $file) {
        $pathinfo = pathinfo($file);
        if ( 'php' === $pathinfo['extension'] ) {
          $class = "hook_{$this->_site}_{$group}_{$pathinfo['filename']}";

          foreach ( get_class_methods(Guarantor::ensure_global($class)) as $method ) {
            if ( substr($method, 0, $this->prefix_length) === self::PREFIX ) {
              $action = substr($method, $this->prefix_length);
              Guarantor::guarantee_all($this->_hooks, $this->_site, $action
                )[$pathinfo['filename']] = [$GLOBALS[$class], $method];
            }
          }
        }
      }

      $this->load($group);
    }

    public function register_page() {
      $this->page = pathinfo($GLOBALS['PHP_SELF'], PATHINFO_FILENAME);
      $this->register($this->page);
      $this->register_pipeline('siteWide');
      $this->call('siteWide', 'injectAppTop');
    }

    public function register_pipeline($pipeline, &$parameters = null) {
      $this->register($pipeline);
      $this->call($this->page, "{$pipeline}Start", $parameters);
    }

    public function set($action, $code, $callable) {
      $hooks =& Guarantor::guarantee_all($this->_hooks, $this->_site, $action);
      $hooks[$code] = $callable;

      uksort($hooks, 'strnatcmp');
    }

    public function call($group, $action, $parameters = []) {
      return $this->cat($action, $parameters);
    }

    public function cat($action, $parameters = []) {
      $result = '';
      foreach ( @(array)$this->_hooks[$this->_site][$action] as $callback ) {
        $result .= call_user_func($callback, $parameters);
      }

      if ( $result ) {
        return $result;
      }
    }

    public function generate($action, $parameters = []) {
      foreach ( @(array)$this->_hooks[$this->_site][$action] as $callback ) {
        yield call_user_func($callback, $parameters);
      }
    }

    public function chain($action, $parameters = []) {
      foreach ( @(array)$this->_hooks[$this->_site][$action] as $callback ) {
        $parameters = call_user_func($callback, $parameters);
      }

      return $parameters;
    }

    public function get_hook_directories() {
      return $this->hook_directories;
    }

  }
ecartz
Lead Developer
Lead Developer
Posts: 1022
Joined: Tue Nov 05, 2019 6:02 pm
Has thanked: 4 times
Been thanked: 93 times

Re: Can't access Admin after update

Post by ecartz »

jimpike wrote: Wed May 05, 2021 1:58 am Undefined index: db in
This suggests that a change was made without a corresponding change. Does the updater support rolling back to the last good version? And then try to go forward again. An alternative would be to copy up the files from the update.

Note that the missing change occurred in the 1.0.8.0 to 1.0.8.1 update and was a modification of an existing file. The change that occurred was a new file.
User avatar
zipurman
PhoenixCart Developer
PhoenixCart Developer
Posts: 179
Joined: Tue Oct 13, 2020 5:20 pm
Location: Canada (CST)
Has thanked: 30 times
Been thanked: 63 times

Re: Can't access Admin after update

Post by zipurman »

Does the updater support rolling back
No, the updater does not support this functionality. It could do a backup every time, but if you are upgrading several versions, it could get complicated if things any errors etc.

You could manually copy the files from the update to see if that fixes anything. @jimpike let me know if you'd like me to have a closer look. You can PM me the details.
zipurman
aka Preston Lord
-----------
Happy to help where I can ;)

https://phoenixaddons.com
https://www.youtube.com/zipurman/ ** PHOENIX HOW-TO VIDEOS **
Image
jimpike
Posts: 6
Joined: Thu Mar 25, 2021 4:47 am
Has thanked: 2 times
Been thanked: 1 time

Re: Can't access Admin after update

Post by jimpike »

Well, I tried uploading the files right from the upgrader folder, from the latest 1.0.8.2 and it still does it.


[edit] So looking more at it, I noticed I was using the wrong admin username (I manage many different sites). Once I put the right username in, I got into the admin area. So it's apparently something wrong with the error page for wrong username.
Post Reply