Support

Admin Tools

#16222 Problem with the scanner send emails.

Posted in ‘Admin Tools for Joomla! 4 & 5’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Environment Information

Joomla! version
n/a
PHP version
n/a
Admin Tools version
n/a

Latest post by nicholas on Wednesday, 05 June 2013 04:56 CDT

user76084
Mandatory information about my setup:

Have I read the related troubleshooter articles above before posting (which pages?)? Yes
Have I searched the tickets before posting? Yes
Have I read the documentation before posting (which pages?)? Yes
Joomla! version: 2.5.11
PHP version: 5.3.20
MySQL version: 5.1.68-cll
Host: (optional, but it helps us help you)
Admin Tools version: 2.5.5

Description of my issue:

PHP File Change scanner sends email from back end just fine, but does not send email if it is run from cron.

Exactly the same behavior as in ticket# 16065

You said that some systems does not understand realpath();
I check my by creating a php file with (<?php echo realpath('robots.txt'); ?>) and when run in browser it returns full path just fine.

I'm not sure what to do but I really need this future.....
Please help.

nicholas
Akeeba Staff
Manager
You said:
I check my by creating a php file with (<?php echo realpath('robots.txt'); ?>) and when run in browser it returns full path just fine.

And here's your false assumption. You run it through the browser, not through a CRON job. The CRON job (which uses a CLI version of PHP) and access through the web use different binaries of PHP with different configurations and different behaviours. That's what I was trying to say in so many words on the other ticket.

That said, there's something you can do. Open the cli/admintools-filescanner.php file in a plain text browser. Find the text between the lines:
define('DS', DIRECTORY_SEPARATOR);

and
class AdminToolsFAM extends JApplicationCli


and replace them with

define('DS', DIRECTORY_SEPARATOR);

// Load system defines
if (file_exists(dirname(__FILE__).'/defines.php')) {
        require_once dirname(__FILE__).'/defines.php';
}

if (!defined('_JDEFINES')) {
        define('JPATH_BASE', dirname(__FILE__).'/../');
        require_once JPATH_BASE.'/includes/defines.php';
}

// Load the rest of the necessary files
include_once JPATH_LIBRARIES.'/import.php';
// Load the rest of the necessary files
include_once JPATH_LIBRARIES.'/import.php';
if(file_exists(JPATH_BASE.'/includes/version.php')) {
	require_once JPATH_BASE.'/includes/version.php';
} else {
	require_once JPATH_LIBRARIES.'/cms.php';
}

JLoader::import( 'joomla.application.cli' );

class AdminToolsFAM extends JApplicationCli


This eliminates realpath() use. If you have exactly the same problem as the other ticket that should help.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

user76084
Hi Nicholas,

I opened that file and try to replace the code, but I have exactly the same code in my admintools-filescanner.php. Actually character by character.... Looks like I have the latest file.....

I know I can do a workaround but I'm not sure if it is safe.

Basically How I made it work is to include real path on instead of /../ ;

original code:
define('JPATH_BASE', dirname(__FILE__).'/../');

Replacement code:
define('JPATH_BASE', dirname(__FILE__).'/home/xxxxx/public_html/');

After that I've got error saying that it could not find JFile in /libraries/fof/config/provider.php
on line 118
So I had to add this code to line 116:

jimport ( 'joomla.filesystem.file' );

So now it is sending emails just fine...

This is done as a test because I'm not sure if it is breaking anything else in my Joomla.....

user76084
BTW...

there is double inclusion of file:

// Load the rest of the necessary files
include_once JPATH_LIBRARIES.'/import.php';
// Load the rest of the necessary files
include_once JPATH_LIBRARIES.'/import.php';

is it OK?

nicholas
Akeeba Staff
Manager
Normally this:
define('JPATH_BASE', dirname(__FILE__).'/home/xxxxx/public_html/');

is wrong and shouldn't work. Since it works it tells me that dirname(__FILE__) returns an empty string which denotes a problem with your hosting that I cannot address in my code. In so many words, dirname(__FILE__) should return the absolute filesystem path to the current file, not an empty string.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

user76084
I guess you right....

What about double include ? is it OK?

nicholas
Akeeba Staff
Manager
The double include doesn't cause a problem, it's just redundant :) You can of course remove the second instance without thinking twice about it.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

user76084
Got you :)

Also I run this php:

<?php

echo dirname(__FILE__); // returns /var/www/html

echo basename(__FILE__); //returns index.php

echo basename(dirname(__FILE__)); //returns html

?>

and again it works in browser, so I guess my Cli is not working here.......

Also Just curious am I breaking anything by manipulating provider.php like that? (adding new inclusion on line 116 ?)

nicholas
Akeeba Staff
Manager
It was a bug in our FOF library which I have now fixed. Your modification is safe and should not be required in the future.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

user76084
Nicholas, I'm sorry... I guess I did not wake up yet......

Here is the code from my admintools-filescanner.php:

if (!defined('_JDEFINES')) {
define('JPATH_BASE', '/home/xxxxx/public_html/');
require_once JPATH_BASE.'/includes/defines.php';

As you can see I eliminated the " dirname(__FILE__).'/../' " altogether.... so Dirname() is not an issue here... Sorry for misleading you....

So what could be wrong in this situation?

nicholas
Akeeba Staff
Manager
Both dirname(__FILE__) . '/../' and the absolute path should be equivalent. I still suspect that __FILE__ in the CLI context gives the wrong path. The PHP file you tried from your browser to see what is output in each case, can you run it through a CRON job and tell me the results?

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

user76084
Hi Nicholas,

I tried the following:

created a 3.php file with this php code:

echo dirname(__FILE__);
echo "   "; 
echo basename(__FILE__);
echo "   ";
echo basename(dirname(__FILE__));


then run this command:
/usr/bin/php5-cli /home/xxxxxx/public_html/3.php 


output of testresults file is here:
/home/xxxxxx/public_html   3.php   public_html


after that I put this command in to the cron. (same command)
/usr/bin/php5-cli /home/xxxxxx/public_html/3.php 


here is the results of that cron job:
/home/xxxxxx/public_html   3.php   public_html


So far the results are identical...

nicholas
Akeeba Staff
Manager
To be perfectly honest, I am not sure what is going on. dirname(__FILE__) returns the correct result. Perhaps the double dot causes a problem, but then again it doesn't happen on my test and live servers. Your guess is as good as mine, I guess :s

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

Support Information

Working hours: We are open Monday to Friday, 9am to 7pm Cyprus timezone (EET / EEST). Support is provided by the same developers writing the software, all of which live in Europe. You can still file tickets outside of our working hours, but we cannot respond to them until we're back at the office.

Support policy: We would like to kindly inform you that when using our support you have already agreed to the Support Policy which is part of our Terms of Service. Thank you for your understanding and for helping us help you!