Server running RHEL 7 and PHP 5.4.16. When I try to open /phpMyAdmin in my browser, I'm given the error:
Fatal error: Call to undefined function __() in /usr/share/phpMyAdmin/libraries/core.lib.php on line 242
Call Stack
# Time Memory Function Location
1 0.0008 348000 {main}( ) ../index.php:0
2 0.0018 503144 require_once( '/usr/share/phpMyAdmin/libraries/common.inc.php' ) ../index.php:12
3 0.0252 4224464 PMA_Config->__construct( ) ../common.inc.php:304
4 0.0252 4224712 PMA_Config->load( ) ../Config.class.php:100
5 0.0265 4309888 PMA_Config->checkConfigSource( ) ../Config.class.php:849
6 0.0265 4311088 PMA_fatalError( ) ../Config.class.php:1169
I believe I've installed all required libraries and that apache has the proper permissions for the session.save_path directory, which were the issues previous times that this question had been asked. See: Call to undefined function __() error - phpMyAdmin
Can someone give me a hint based on that call stack?
Here are the functions from the lines that the stack trace references, with the relevant line written in the left margin:
core.lib.php at line 242:
/**
* displays the given error message on phpMyAdmin error page in foreign language,
* ends script execution and closes session
*
* loads language file if not loaded already
*
* #param string $error_message the error message or named error message
* #param string|array $message_args arguments applied to $error_message
* #param boolean $delete_session whether to delete session cookie
*
* #return void
*/
function PMA_fatalError(
$error_message, $message_args = null, $delete_session = true
) {
/* Use format string if applicable */
if (is_string($message_args)) {
$error_message = sprintf($error_message, $message_args);
} elseif (is_array($message_args)) {
$error_message = vsprintf($error_message, $message_args);
}
if ($GLOBALS['is_ajax_request']) {
$response = PMA_Response::getInstance();
$response->isSuccess(false);
$response->addJSON('message', PMA_Message::error($error_message));
} else {
$error_message = strtr($error_message, array('<br />' => '[br]'));
/* Load gettext for fatal errors */
if (!function_exists('__')) {
// It is possible that PMA_fatalError() is called before including
// vendor_config.php which defines GETTEXT_INC. See bug #4557
if (defined(GETTEXT_INC)) {
include_once GETTEXT_INC;
} else {
include_once './libraries/php-gettext/gettext.inc';
}
}
// these variables are used in the included file libraries/error.inc.php
242 $error_header = __('Error');
$lang = $GLOBALS['available_languages'][$GLOBALS['lang']][1];
$dir = $GLOBALS['text_dir'];
// on fatal errors it cannot hurt to always delete the current session
if ($delete_session
&& isset($GLOBALS['session_name'])
&& isset($_COOKIE[$GLOBALS['session_name']])
) {
$GLOBALS['PMA_Config']->removeCookie($GLOBALS['session_name']);
}
// Displays the error message
include './libraries/error.inc.php';
}
if (! defined('TESTSUITE')) {
exit;
}
}
common.inc.php at line 304:
304 $GLOBALS['PMA_Config'] = new PMA_Config(CONFIG_FILE);
if (!defined('PMA_MINIMUM_COMMON')) {
$GLOBALS['PMA_Config']->checkPmaAbsoluteUri();
}
Config.class.php at line 100:
/**
* constructor
*
* #param string $source source to read config from
*/
function __construct($source = null)
{
$this->settings = array();
// functions need to refresh in case of config file changed goes in
// PMA_Config::load()
100 $this->load($source);
// other settings, independent from config file, comes in
$this->checkSystem();
$this->isHttps();
$this->base_settings = $this->settings;
}
Config.class.php at line 849:
/**
* loads configuration from $source, usually the config file
* should be called on object creation
*
* #param string $source config file
*
* #return bool
*/
function load($source = null)
{
$this->loadDefaults();
if (null !== $source) {
$this->setSource($source);
}
/**
* We check and set the font size at this point, to make the font size
* selector work also for users without a config.inc.php
*/
$this->checkFontsize();
if (! $this->checkConfigSource()) {
849 return false;
}
Config.class.php at line 1169:
/**
* check config source
*
* #return boolean whether source is valid or not
*/
function checkConfigSource()
{
if (! $this->getSource()) {
// no configuration file set at all
return false;
}
if (! file_exists($this->getSource())) {
$this->source_mtime = 0;
return false;
}
if (! is_readable($this->getSource())) {
// manually check if file is readable
// might be bug #3059806 Supporting running from CIFS/Samba shares
$contents = false;
$handle = #fopen($this->getSource(), 'r');
if ($handle !== false) {
$contents = #fread($handle, 1); // reading 1 byte is enough to test
#fclose($handle);
}
if ($contents === false) {
$this->source_mtime = 0;
PMA_fatalError(
sprintf(
function_exists('__')
? __('Existing configuration file (%s) is not readable.')
: 'Existing configuration file (%s) is not readable.',
$this->getSource()
)
1169 );
return false;
}
}
return true;
}
The problem was the wrong permissions for the /etc/phpMyAdmin directory. The web server user, apache, had proper permissions for the session.save_path directory, but apache couldn't read from my config.inc.php file. Changing the owner of /etc/phpMyAdmin to the apache user and changing the permissions to 755 solved the problem.
Looking at the checkConfigSource() function in Config.class.php led me to believe that if the problem was with accessing the configuration file then I would have received the error 'Existing configuration file (%s) is not readable.' instead of Call to undefined function __() Does anyone know why that wasn't the case?
This was a pretty basic problem/solution, but unless someone suggests otherwise I think I'll leave it up since this exact problem/solution isn't addressed in other discussions of the Fatal error: Call to undefined function __() in /usr/share/phpMyAdmin/libraries/core.lib.php error when trying to start phpMyAdmin after installation.
Had the same Error message from phpMyAdmin ::
FastCGI sent in stderr: "PHP message: PHP Fatal error: Call to undefined function __() in /usr/share/phpMyAdmin/libraries/core.lib.php on line 245" while reading response header from upstream, client:
Solution that worked on my Fedora 22 server x86_64 using nginx :
changing the owner and the group identifier from root:apache on the file /var/lib/php/session
to root:nginx
using the command sudo chown -Rfv root:nginx /var/lib/php/session.
If phpmyadmin was working fine and then suddenly stops working for no reason with a bizarre and useless error message, you might try deleting your php sessions.
rm -rf /var/lib/php/sessions/*
The exact location may very depending on OS and version, and this will delete all active sessions, not just yours, but it can fix some "suddenly stopped working" issues when you haven't changed anything and it was working fine before.
For me it was different issue. I had given 777 permissions to phpMyAdmin forlder. When I changed it to 755, it worked fine.
Hope this will help someone.
Error "The connection was reset" File:
/usr/share/phpmyadmin/libraries/common.inc.php
search:
$GLOBALS['PMA_Config'] = new PMA_Config(CONFIG_FILE);<br>
replace with:
$GLOBALS['PMA_Config'] = new PMA_Config();
Related
I want to use adminer without password.
I uploaded adminer-4.7.7-en.php file and finding login-password-less plugin
I create file plugins/login-password-less.php with content :
<?php
/** Enable login for password-less database
* #link https://www.adminer.org/plugins/#use
* #author Jakub Vrana, https://www.vrana.cz/
* #license https://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* #license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
*/
class AdminerLoginPasswordLess {
/** #access protected */
var $password_hash;
/** Set allowed password
* #param string result of password_hash
*/
function __construct($password_hash) {
$this->password_hash = $password_hash;
}
function credentials() {
$password = get_password();
return array(SERVER, $_GET["username"], (password_verify($password, $this->password_hash) ? "" : $password));
}
function login($login, $password) {
if ($password != "") {
return true;
}
}
}
and reading https://www.adminer.org/plugins/#use I created file adminer.php, which is
located in one dir with adminer-4.7.7-en.php and I created new apache host pointed at this file.
This file has :
<?php
function adminer_object() {
// required to run any plugin
include_once "./plugins/login-password-less.php"; // Plugin I want to use
// autoloader
foreach (glob("plugins/*.php") as $filename) {
include_once "./$filename";
}
$plugins = array(
// specify enabled plugins here
new AdminerLoginPasswordLess, // Plugin I want to use
/* new AdminerTinymce,
new AdminerFileUpload("data/"),
new AdminerSlugify,
new AdminerTranslation,
new AdminerForeignSystem,*/
);
/* It is possible to combine customization and plugins:
class AdminerCustomization extends AdminerPlugin {
}
return new AdminerCustomization($plugins);
*/
return new AdminerPlugin($plugins); // I am not sure which class is it and where it is defined ?
}
// include original Adminer or Adminer Editor
include "./adminer-4.7.7-en.php"; // encoded file I uploaded
?>
and I got error:
Fatal error: Uncaught ArgumentCountError: Too few arguments to function AdminerLoginPasswordLess::__construct(), 0 passed in /mnt/_work_sdb8/wwwroot/lar/local_adminer/adminer.php on line 13 and exactly 1 expected in /mnt/_work_sdb8/wwwroot/lar/local_adminer/plugins/login-password-less.php:16 Stack trace: #0 /mnt/_work_sdb8/wwwroot/lar/local_adminer/adminer.php(13): AdminerLoginPasswordLess->__construct() #1 /mnt/_work_sdb8/wwwroot/lar/local_adminer/adminer-4.7.7-en.php(1654): adminer_object() #2 /mnt/_work_sdb8/wwwroot/lar/local_adminer/adminer.php(31): include('/mnt/_work_sdb8...') #3 {main} thrown in /mnt/_work_sdb8/wwwroot/lar/local_adminer/plugins/login-password-less.php on line 16
Which is the valid way to use adminer without password ?
MODIFIED:
I made :
new AdminerLoginPasswordLess(hash("md5", 'my_sql_user_password')),
Is the selected "md5" method valid ?
But I got error :
Fatal error: Uncaught Error: Class 'AdminerPlugin' not found in /mnt/_work_sdb8/wwwroot/lar/local_adminer/adminer.php:32 Stack trace: #0 /mnt/_work_sdb8/wwwroot/lar/local_adminer/adminer-4.7.7-en.php(1654): adminer_object() #1 /mnt/_work_sdb8/wwwroot/lar/local_adminer/adminer.php(36): include('/mnt/_work_sdb8...') #2 {main} thrown in /mnt/_work_sdb8/wwwroot/lar/local_adminer/adminer.php on line 32
MODIFIED:
In source version of the site I foun file plugin.php with AdminerPlugin class implementation.
I moved this file under plugins directory.
In plugins/login-password-less.php I added reference to plugins/plugin.php file and added debugging info :
<?php
/** Enable login for password-less database
* #link https://www.adminer.org/plugins/#use
* #author Jakub Vrana, https://www.vrana.cz/
* #license https://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* #license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
*/
include_once "./plugins/plugin.php";
class AdminerLoginPasswordLess {
/** #access protected */
var $password_hash;
/** Set allowed password
* #param string result of password_hash
*/
function __construct($password_hash) {
$this->password_hash = $password_hash;
debToFile('-2 AdminerLoginPasswordLess->__construct:$this->password_hash::'.$this->password_hash);
// That is debugging method appending string into text file
}
function credentials() {
$password = get_password();
debToFile('-3 AdminerLoginPasswordLess->credentials:$password::'.$password);
// That is debugging method appending string into text file
return array(SERVER, $_GET["username"], (password_verify($password, $this->password_hash) ? "" : $password));
}
function login($login, $password) {
debToFile('-4 AdminerLoginPasswordLess->login:$login::'.$login);
if ($password != "") {
debToFile('-5 TRUE AdminerLoginPasswordLess->login:$login::'.$login);
// That is debugging method appending string into text file
return true;
}
debToFile('-5 false AdminerLoginPasswordLess->login:$login::'.$login);
}
}
and in adminer.php I added debugging line:
$plugins = array(
new AdminerLoginPasswordLess(hash("md5", 'm8y2s8q&L')),
);
debToFile('-1After:AdminerLoginPasswordLess');
I loggin file I see:
<pre>::-2 AdminerLoginPasswordLess->__construct:$this->password_hash::c61d49aaab35ca428e60d764ff05159d</pre>
<pre>::-1After:AdminerLoginPasswordLess</pre>
It means that methods credentials and login of AdminerLoginPasswordLess class are not triggered.
I run in browser as :
http://local-adminer.com/?username=mysql_login_user
or
http://local-adminer.com // host in apache config
and I have no errors, but I still have to enter password for mysql_login_user.
Did I miss some options/plugins?
Thanks!
first do
mkdir -p plugins;
wget -O plugins/plugin.php https://raw.githubusercontent.com/vrana/adminer/master/plugins/plugin.php;
nano plugins/passwordless_login.php
then write
<?php
class AdminerLoginPasswordLess {
public function credentials() {
return array("mysql_hostname", "mysql_username", "mysql_password");
}
function login($login, $password) {
return true;
}
}
then save and exit, then run nano adminer_with_plugins.php and write:
<?php
function adminer_object() {
// required to run any plugin
include_once "./plugins/plugin.php";
// "autoloader"
foreach (glob("plugins/*.php") as $filename) {
include_once "./$filename";
}
$plugins = array(
// specify enabled plugins here
new AdminerLoginPasswordLess,
//new AdminerDumpXml,
//new AdminerTinymce,
//new AdminerFileUpload("data/"),
//new AdminerSlugify,
//new AdminerTranslation,
//new AdminerForeignSystem,
);
return new AdminerPlugin($plugins);
}
// include original Adminer or Adminer Editor
include "./adminer.php";
then save & exit;
then point your web-browser to adminer_with_plugins.php instead of adminer.php, now you have effectively disabled adminer's ability to login with different usernames/passwords/hosts, no matter what credentials you try to login with, it will always login with the mysql_hostname/mysql_username/mysql_password written in the source code, ignoring the user input credentials.
needless to say, this is quite a security-sensitive operation.
It often saves time if you can bypass small time consuming tasks. I tried above methods but did not work for me so I did the following which works in 2021 for Adminer 4.7.9.
WARNING: Please note that its only for your local machine & not advised for online databases.:
Step-1: Download Adminer source from Github, this link.
Step-2: Open adminer-master\adminer\include\auth.inc.php
Step-3: Edit the following at lines 55 to 57 & replace my_username & my_password with your MySQL credentials:
$server = "localhost"; //$auth["server"];
$username = "my_username"; //$auth["username"];
$password = "my_password"; //(string) $auth["password"];
Step-4: Save & now open Adminer by pointing your browser to "adminer-master\adminer"
Step-5: Just click Login button & you will login without entering anything.
Hope it will work for you.
Just finished migrating a Magento website to a new server. Using the following steps:
-Backup the database in the backend
-Import the database on new server
-Copy all files from old server to new server
-Set correct file permissions
-Update /app/etc/local.xml
-Update secure and unsecure base_url in database
-Remove cache and session files
The website itself works fine, but it seems to give a fatal error on the order button now (see screenshot of source)
This is the block of code the error refers to:
/**
* Product type instance factory
*
* #param Mage_Catalog_Model_Product $product
* #param bool $singleton
* #return Mage_Catalog_Model_Product_Type_Abstract
*/
public static function factory($product, $singleton = false)
{
$types = self::getTypes();
$typeId = $product->getTypeId();
if (!empty($types[$typeId]['model'])) {
$typeModelName = $types[$typeId]['model'];
} else {
$typeModelName = self::DEFAULT_TYPE_MODEL;
$typeId = self::DEFAULT_TYPE;
}
if ($singleton === true) {
$typeModel = Mage::getSingleton($typeModelName);
}
else {
$typeModel = Mage::getModel($typeModelName);
$typeModel->setProduct($product);
}
$typeModel->setConfig($types[$typeId]); /**this is line 80**/
return $typeModel;
}
I also tried to make a fresh install and copy the needed files, but that did not work either.
This is my first time working with Magento, and searching online for a solution did not bring up anything useful to me. Could anyone point me to the right direction?
I am running into this fatal error, and have no idea why it is generated. Any help will be very appreciated. This website is working online, but once I download it ot my system, it shows this error.
The Error Message is:
Fatal error: Call to undefined method Exception::get() in C:\wamp\www\motor_racing_server\templates\yoo_shelf\error.php on line 20
For Further information:
I have already updated the configuration.php file variables. below is the list of files changed.
public $dbtype = 'mysql';
public $host = 'localhost';
public $user = 'root';
public $password = '';
public $db = 'motor_racing_joomla';
public $log_path = 'C:\\wamp\\www\\NEW_JOOMLA\\logs';
public $tmp_path = 'C:\\wamp\\www\\NEW_JOOMLA\\tmp';
P.S The database name is correct, i have already checked it.
The error.php code is below
<?php
/**
* #package yoo_shelf
* #author YOOtheme http://www.yootheme.com
* #copyright Copyright (C) YOOtheme GmbH
* #license http://www.gnu.org/licenses/gpl.html GNU/GPL
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
// include config
include_once(dirname(__FILE__).'/config.php');
// get warp
$warp = Warp::getInstance();
// set messages
$title = $this->title; // line 19
$error = $this->error->get('code'); // line 20
$message = $this->error->get('message'); // line 21
// set 404 messages
if ($error == '404') {
$title = JText::_('TPL_WARP_404_PAGE_TITLE');
$message = JText::sprintf('TPL_WARP_404_PAGE_MESSAGE', JURI::root(false), $warp['config']->get('site_name'));
}
// render error layout
echo $warp['template']->render('error', compact('title', 'error', 'message'));
I tried to remove the line 20, the code generate the same error for line 21. And after commenting out both line 20, and line 21, I got an error "Error 500".
I have fixed the problem, in two steps.
I re-download all the files from the server, and that fix the problem.
I still have no Idea what was missing.
Secondly, I configure new joomla application on my system, and then compare the two configuartion files (from server site and one configured on localhost), and change the variables excep the one related to database.
I moved our existing Magento site to my hosting account for development work but when I try to access anywhere on the backend of the site other than the admin dashboard I get the following error:
Fatal error: Class 'Mage_Adminhtml_Block_Widget_Form_Renderer_Fieldset_Element' not found in /magento/app/code/core/Mage/Core/Model/Layout.php on line 491
In the database core_config_data table I've changed the web/unsecure/base_url and web/secure/base_url to match the new domain name.
In the .htaccess file I've changed the RewriteBase / to use the new folder path.
The error I'm getting refers to line 491 in the Layout.php file which is the 4th if clause of the below function:
/**
* Create block object instance based on block type
*
* #param string $block
* #param array $attributes
* #return Mage_Core_Block_Abstract
*/
protected function _getBlockInstance($block, array $attributes=array())
{
if (is_string($block)) {
if (strpos($block, '/')!==false) {
if (!$block = Mage::getConfig()->getBlockClassName($block)) {
Mage::throwException(Mage::helper('core')->__('Invalid block type: %s', $block));
}
}
if (class_exists($block, false) || mageFindClassFile($block)) {
$block = new $block($attributes);
}
}
if (!$block instanceof Mage_Core_Block_Abstract) {
Mage::throwException(Mage::helper('core')->__('Invalid block type: %s', $block));
}
return $block;
}
#waldek_c comment above really helped me solve this but i thought I put an answer up myself to complete the question in case anyone else ran into something similar.
The error message itself was pointing me to the issue.
Mage_Adminhtml_Block_Widget_Form_Renderer_Fieldset_Element was the path to the file causing the issue. As it turned out the file did not upload correctly when I was uploading the site.
I'm trying to access an FTP server from my PHP script using Codeigniter's FTP Library. These functions work great, but when testing the script I discovered that if I attempt to connect to a server that does not exist, the script does not terminate with an error message of any kind.
The page continues to execute, until the web server gives up, returning an empty document.
So I am wondering, is there a way to limit the amount of time that Codeigniter can try to connect to an FTP server, then display a message if that times out?
I tried using the php function set_time_limit(), but it does not behave how I expected it to.
Thanks for your help.
Codeigniter's ftp class uses the underlying ftp_connect php call that supports a 3rd optional parameter, timeout (http://ca2.php.net/manual/en/function.ftp-connect.php).
Codeigniter however does not use it, but allows for extending the default libraries it provides (providing that you're willing to do some work and check that any updates you do to the core will not break the functionality of your extended class). So to solve your problem you could create a new library in you application library folder:
<?php
class MY_FTP extends CI_FTP { //Assuming that in your config.php file, your subclass prefix is set to 'MY_' like so: $config['subclass_prefix'] = 'MY_';
var $timeout = 90;
/**
* FTP Connect
*
* #access public
* #param array the connection values
* #return bool
*/
function connect($config = array())
{
if (count($config) > 0)
{
$this->initialize($config);
}
if (FALSE === ($this->conn_id = ftp_connect($this->hostname, $this->port, $this->timeout)))
{
if ($this->debug == TRUE)
{
$this->_error('ftp_unable_to_connect');
}
return FALSE;
}
if ( ! $this->_login())
{
if ($this->debug == TRUE)
{
$this->_error('ftp_unable_to_login');
}
return FALSE;
}
// Set passive mode if needed
if ($this->passive == TRUE)
{
ftp_pasv($this->conn_id, TRUE);
}
return TRUE;
}
}
?>
and from your script, you could add to your configuration array the timeout option:
$this->load->library('ftp'); //if ftp is not autoloaded
$ftp_params = array('hostname'=>'1.2.3.4', 'port'=>21, 'timeout'=>10); //timout is 10 seconds instead of default 90
$ftp_conn = $this->ftp->connect($ftp_params);
if(FALSE === $ftp_conn) {
//Code to handle error
}
The ftp class is not designed to give error messages unless the debug parameter is set to TRUE in te config array, in which case it'll just display an error. However it can also be override, because all errors call the function _error() in the class. So you could set 'debug' => true in your $ftp_params array, and add a function in MY_ftp like so:
/**
* This function overrides
*/
function _error($line)
{
$this->error = $line;
}
And then have a function getError()
/**
* This function overrides
*/
function get_error()
{
return $this->error;
}
So if
$ftp_conn = $this->ftp->connect($ftp_params);
returns false, you can call
$error = $this->ftp->get_error();
to get your error and display it.
Now, you can always customize and have a more complex error handling mechanism by further customizing the class...
Hope it answers your question.
The answer is simple, don't attempt to connect to a server that doesn't exist.