[RESOLVED] Include plugin library

Get help from other users here.

Moderators: Developer, Contributor

Post Reply
Lisandro1987
Posts: 19
Joined: 02 Oct 2012, 13:56

[RESOLVED] Include plugin library

Post by Lisandro1987 »

I need to create a cronjob that execute a PHP file. But I have a problem when when I try to run the file by console typing:

If I run in the console:

Code: Select all

[USER]@[HOSTNAME]:~$ php [PUBLIC_HTML]/plugins/TestPlugin/pages/index.php
PHP Deprecated:  Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/mcrypt.ini on line 1 in Unknown on line 0
<p style="color:red">APPLICATION WARNING #100: Configuration option "plugin__test" not found.</p>
I think that the problem happen when I call 'plugin_config_get'. How can I to include this library? I try:

Code: Select all

[PUBLIC_HTML]/plugins/TestPlugin/pages/index.php
<?php
require_once(dirname(__FILE__)."/../../../core.php");
$g_test = plugin_config_get('test');
echo $g_test;
?>
But do not work. If I run in browser works perfectly! What can I do?
Last edited by Lisandro1987 on 08 Nov 2012, 17:23, edited 2 times in total.
Lapinkiller
Posts: 408
Joined: 28 Jan 2011, 18:47
Location: France
Contact:

Re: Include plugin library

Post by Lapinkiller »

hello,

do a require_once on file {mantisroot}/core.php
Lapinkiller,
French PHP developer
New look for your mantis : http://www.mantisbt.org/forums/viewtopi ... =4&t=20055
Lisandro1987
Posts: 19
Joined: 02 Oct 2012, 13:56

Re: Include plugin library

Post by Lisandro1987 »

Thanks so much for your answer, but that don't work:

[PUBLIC_HTML]/plugins/TestPlugin/pages/index.php

Code: Select all

<?php

require_once(dirname(__FILE__)."/../../../config_inc.php");
require_once(dirname(__FILE__)."/../../../core.php");

$connection = mysql_connect($g_hostname, $g_db_username, $g_db_password);
mysql_select_db($g_database_name, $connection);

$g_test = plugin_config_get('t_test');

echo $g_test;

?>
If i run that in console, the next error appear:

Code: Select all

[USER]@[HOSTNAME]:~$ php [PUBLIC_HTML]/plugins/TestPlugin/pages/index.php 
PHP Deprecated:  Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/mcrypt.ini on line 1 in Unknown on line 0
<html><head><title>APPLICATION ERROR #400</title></head><body><br /><div align="center"><table class="width50" cellspacing="1"><tr><td class="form-title">APPLICATION ERROR #400</td></tr><tr><td><p class="center" style="color:red">Database connection failed. Error received from database was #1045: Access denied for user 'root'@'localhost' (using password: NO).</p></td></tr><tr><td><p class="center">Please use the "Back" button in your web browser to return to the previous page. There you can correct whatever problems were identified in this error or select another action. You can also click an option from the menu bar to go directly to a new section.</p></td></tr></table></div><p>Previous non-fatal errors occurred.  Page contents follow.</p><div style="border: solid 1px black;padding: 4px"><p style="color:red">SYSTEM WARNING: mysql_connect(): Access denied for user 'root'@'localhost' (using password: NO)</p></div></body></html>
Lapinkiller
Posts: 408
Joined: 28 Jan 2011, 18:47
Location: France
Contact:

Re: Include plugin library

Post by Lapinkiller »

the inclusion works..

the problem is with your code, you don't have to do the db connetion, use database api which is loaded by core.php
Lapinkiller,
French PHP developer
New look for your mantis : http://www.mantisbt.org/forums/viewtopi ... =4&t=20055
Lisandro1987
Posts: 19
Joined: 02 Oct 2012, 13:56

Re: Include plugin library

Post by Lisandro1987 »

Thanks for your answer. But if I don't include the connection to the database it is still not working:

Code: Select all

[PUBLIC_HTML]/plugins/TestPlugin/pages/index.php
<?php
require_once(dirname(__FILE__)."/../../../core.php");
$g_test = plugin_config_get('test');
echo $g_test;
?>
If I run in the console:

Code: Select all

[USER]@[HOSTNAME]:~$ php [PUBLIC_HTML]/plugins/TestPlugin/pages/index.php
PHP Deprecated:  Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/mcrypt.ini on line 1 in Unknown on line 0
<p style="color:red">APPLICATION WARNING #100: Configuration option "plugin__test" not found.</p>
If I run in browser works perfectly!
Lisandro1987
Posts: 19
Joined: 02 Oct 2012, 13:56

Re: Include plugin library

Post by Lisandro1987 »

Can anyone help me? :(
Lisandro1987
Posts: 19
Joined: 02 Oct 2012, 13:56

Re: Include plugin library

Post by Lisandro1987 »

I resolved this using command 'lynk'. Thanks!
Post Reply