DirectPHP plugin |
| Written by kksou | ||||||||
| Monday, 24 March 2008 | ||||||||
This plugin allows direct embedding of PHP commands right inside Joomla content page for dynamic contents. Available for all Joomla versions: Joomla 1.0.x, native 1.5.x, 1.6.x, 1.7.x,2.5.x and 3.0.x! Very Important: If you're using Joomla 1.6 or Joomla 1.7, don't forget to set the Filter Type to "No Filtering" so that you can enter PHP codes in a Joomla 1.6 / 1.7 articles. Details here (works for both Joomla 1.6 and 1.7). If you're using Joomla 1.5, please refer to the article: Table of Contents
Key Features
<?php php_commands... ?> Now is: <?php echo date('Y-m-d H:i:s');?>
<?php
require_once('fullpath/your_lib.php');
your_php_func();
?>
Latest version v3.0 (for Joomla 3.0) Native version of DirectPHP for Joomla 3.0! Don't forget to set the Filter Type to "No Filtering" so that you can enter PHP codes in a Joomla 3.0 article using the default WYSIWYG editor. Details here. BackgroundI've recently redesigned this website using Joomla. As you can see, there are more than 450 PHP-GTK sample codes. It's just too much a hassle to include each sample code into every article. Isn't it nice if I could do a simple echo "<pre>".htmlentities('filename.php')."</pre>";
to automatically include the respective sample code? I've tried two other plugins: Jumi and RunPHP .
So I decided to develop my own plugin, and the result is this plugin DirectPHP. How to install (Joomla 1.0.x)
Current date and time is: <?php echo date('Y-m-d H:i:s');?>
To customize the block list (Joomla 1.0.x)
How to install (Joomla 1.5.x)
Current date and time is: <?php echo date('Y-m-d H:i:s');?>
To customize the block list (Joomla 1.5.x)
ExamplesHere are some examples:
Now is: <?php echo date('l j D, Y H:i:s');?>
<?php
for ($i=0; $i<10; ++$i) {
echo "$i: ".$i*$i,"<br>";
}
?>
<?php
require_once('/fullpath/your_php_library.php');
display_image('image123.jpg');
?>
<?php global $a;
$a = 10;?>
This is a test. variable $a = <?php echo $a;?>
<?php
function f1() {
global $a;
return $a*2;
}
$b = f1($a);
?>
You can access variable $a from within the function with global.
variable $b = <?php echo $b;?>
<?php echo "<table border=4$gt;"; echo "<tr><td>a11</td><td>a12</td></tr>"; echo "<tr><td>a11</td><td>a12</td></tr>"; echo "</table>"; ?> For Joomla 1.0: <?php
global $my;
if ($my->id==0) {
// non-registered members
print "Please register or login.";
} else {
// registered members
print "Contents for registered members.";
}
?>
For Joomla 1.5: <?php
$user =& JFactory::getUser();
if ($user->id==0) {
// non-registered members
print "Please register or login.";
} else {
// registered members
print "Contents for registered members.";
}
?>
Important Note: Blocking of PHP commandsBy default, I've blocked some of the potentially "risky" commands, e.g. system, fopen, unlink, rmdir, etc. You can view the entire list of PHP commands that are blocked in the plugin's property page. In there, you can also add, edit or delete this list of commands to suit your needs. If you need to use any of these commands (e.g. mkdir) from within the content page, put them in one of the library files on your server, do a If you insist, you may choose to turn off the blocking in the property page. However, I would strongly advise that you do so only if you're the only one maintaining your Joomla site. If you're opening up the adding and editing of content pages to the public, DO NOT turn off the blocking. It's too dangerous. DisclaimerDirectPHP is a simple, yet flexible and powerful plugin. I'm using it on this website. I'm sharing with you here because I think it will be very useful to some of you. Your use of this plugin is at your own risk. kksou.com makes no warranties or representations, express or implied, as to the functionality or usefulness of this plugin. kksou.com disclaims all warranties, express or implied, including without limitation warranties of merchantability and fitness for a particular purpose. kksou.com disclaims liability for any direct, indirect, incidental, consequential, special, exemplary, punitive or other damages, or lost profits, that may result, directly or indirectly, from your use of this plugin, including without limitation any damage to computer systems, hardware or software, loss of data, or any other performance failures, or any errors, bugs, viruses or other defects that result from or are associated with use of this plugin. Be a SponsorIf you find this plugin useful, Secure Payments by PayPal. DownloadDirectPHP for Joomla 1.0.x: DirectPHP_v1.06
DirectPHP for Joomla 1.5.x: DirectPHP_v1.56 DirectPHP for Joomla 1.6.x: DirectPHP_v1.6 DirectPHP for Joomla 1.7.x: DirectPHP_v1.7 DirectPHP for Joomla 2.5.x: DirectPHP_v2.5 DirectPHP for Joomla 3.0.x: DirectPHP_v3.0 Don't forget to set the Filter Type to "No Filtering" so that you can enter PHP codes in a Joomla 1.6/1.7/2.5 articles. Details here for Joomla 1.6/1.7 Details here for Joomla 2.5. Note: To upgrade to the newer version, simply uninstall the old version and install the new version of the plugin. Version History
In TinyMCE Editor, when you press Enter, internally it's stored as a <p>. If you press shift-Enter, internally it's stored as <br>. In v1.00, if the user presses Enter after "<?php", the php script will not be captured. I only preg_matched for <br>. Overlooked the case for <p>. Bug has been fixed. In some of the editors, tabs is internally stored as &160;. If you're using tabs for code indentation, please download this update. Encapsulate all functions used by DirectPHP within a class so that you can use DirectPHP with some other plugins such as the "DirectPHP for Category Description" plugin. Now supports both PHP5 and PHP4. Thanks to Salvatore who informed me about some "mysterious" double-byte characters that get inserted into the DirectPHP code by the content editor of some of the non-English Joomla. These double-byte characters will cause error when processing the PHP commands with eval(). Have fixed this in this version. Added one more parameter "Using No Editor". If you're not using any editor when editing content articles, select 'yes' for this parameter. This will allow you to freely use any HTML tags (such as <br /> or <p>). Native version of DirectPHP for Joomla 1.6! Don't forget to set the Filter Type to "No Filtering" so that you can enter PHP codes in a Joomla 1.6 articles. Details here. Native version of DirectPHP for Joomla 1.7! Don't forget to set the Filter Type to "No Filtering" so that you can enter PHP codes in a Joomla 1.7 article using the default WYSIWYG editor. Details here (works for both Joomla 1.6 and 1.7). Native version of DirectPHP for Joomla 2.5! Don't forget to set the Filter Type to "No Filtering" so that you can enter PHP codes in a Joomla 2.5 article using the default WYSIWYG editor. Details here. |
||||||||
| < Prev |
|---|







Comments
1) what have you tried?
2) what are the tags that you are using? 3) what are the error messages that you see on the screen?
4) Can you try just a simple PHP statement such as echo "test123".
Does this work? Did you see the string "test123" on the screen?
Regards,
/kksou
thanks for answer. I have tried to add directly in article one complete file php that is a part of script but not work.
First of all, DirectPHP is not originally designed to be used to enter complicated PHP codes. I wrote it originally to allow myself to enter simple PHP codes here and there in a Joomla article. If you need to include complicated PHP codes, you might want to write a plugin for that purpose. It's cleaner and easier to debug that way.
Besides, note that this is a plugin. As the name suggests, you are running PHP codes within the Joomla framework. So NOT ALL php scripts will run within your Joomla article.
If you are still keen to try DirectPHP, please try something simpler first, such as echo "test123";
This will allow you to know if DirectPHP works at all on your server.
Once you are certain that DirectPHP runs on your server, you can try adding more complicated PHP commands to see if it works within your Joomla article.
Again, just want to emphasize again you are running PHP script within the Joomla framework. So NOT ALL scripts will run. You need some trials and errors to test it out.
Regards,
/kksou
Is it works on Joomla 2.5?
Have just released DirectPHP for Joomla 2.5!
Regards,
/kksou
it does not work :-( why?
Your code didn't appear.
Would you like to email the code to me?
Regards,
/kksou
I've got j 2.5 and I've gone through all steps and installed plugin.
However each time i write article content with tinyMCE like:
Now is:
it keeps changing it to:
Now is:
Any hints? I turned the filtering off
Quoting sqrl:
As the name says, this is a plugin.
So you will see it in the Plugin Manager and not Module Manager.
Regards,
/kksou
p.s. as this is a plugin, it's for use within an article. You can create a new article and test running some PHP commands from within the article.
Parse error: syntax error, unexpected $end, expecting ',' or ';' in Z:\home\localho st\www\comfy-yard\plugins\co ntent\DirectPHP \DirectPHP.php(57) : eval()'d code on line 1
DirectPHP process PHP statements using the standard PHP's eval() function.
The error messages simply means there's some error in your code.
It's every difficult to debug based on the error message returned from the eval() statement. Would suggest you copy and paste your codes into a plain .php file and try running that .php file. You will get more meaningful error message that tells you where and what the error is.
Regards,
/kksou
Thanks again.
Sorry for the late reply.
Let me answer your second question first. With DirectPHP, you can have dynamic contents within an article. You can also display and process things like forms within an article. Of course, there are many things you can achieve using the method you have just mentioned, i.e. putting the PHP into a module and then loading its position from an article. However, I think you can see that this is an "indirect" method - as oppose to Joomla running the PHP codes directly in the article. Second, there are some things you cannot do using the "module" method. e.g. if you are using the googleMaps plugin, I can use PHP to generate a dynamic tag to display different google maps every time depending on the user or the content. I can also use PHP to choose which content plugins to run depending on situations.
As for yoru first question, this is the reason why I put a "Disclaimer" just before the downloading section of this page - it's powerful, but you have to use this at your own risk. (This is true for any other plugins that allow you to input PHP.) If you are the administrator for your website, and you know what you are doing, then using this is relatively safe. But if you website has many authors and publishers, then I would be a bit worried using this type of tools too.
Hope this helps.
Regards,
/kksou
I must include the php in an article so the client can modify prices later. I was using JCE editor, and switched to tinyMCE. Site is v1.6.
I followed all your instructions, set Article Manager filtering to none for Super Users and Admin. It was already set for Super Users. I inserted the script into the page it belongs on, complete with '' at the beginning and end. No other text or code was included. The script is 138 lines. Is that too long for this plugin to handle?
I also tested just '' to see if a short script would work. All I get is the entire php script, the short or long one, displaying on the page, with tags. Is this enough info to determine what I may have done wrong?
I was explaining that I used php tags in the long script, and tried a simple one sentence echo statement to see if the long script was the problem. Neither worked. I would understand if the longer script didn't work and the shorter one did, but that's not the case. Many thanks.
When using the default Joomla editor, please DO NOT use the HTML mode. Use the wysiwyg mode.
Please try just one line:
echo 'test123';
first and see if works.
DirectPHP can work with multiple lines - it's just that debugging is very difficult.
In any case, please try the above one more time and let me know if it works.
Regards,
/kksou
This exact same 138 line file works fine in a WAMP environment, serving up IE. The code returns and displays the calculations.
Would there be a difference between the code a WAMP server can use and code in a Joomla article?
and when I load the public page I get the following error message: Parse error syntax error unexpected '.' in /public_html/n/plugins/content/DirectPHP/DirectPHP.php(58): eval()'d code on line 1
Thank you for your time,
Chris
Your entire code is processed by the standard PHP eval() statement. As such it's very difficult to debug anything from the error message.
Would suggest you copy the entire PHP code into a standalone PHP file.
1) First try if your standalone .php file runs at all. If it doesn't run, the error messages returned by the PHP interpreter will be more meaningful and easier to debug.
2) Once your standalone PHP file runs ok, you can use DirectPHP from within your Joomla article and do a require() or include() to include your PHP code. See if the code now runs.
3) Once (2) works, you can then try to copy and paste your PHP codes from the standalone PHP file back into the article. See if it works.
Note that even if (1) works, it does not necessarily means (2) and (3) will work. Bear in mind that you are running your codes within the Joomla framework - so not all PHP codes will run the same within Joomla. This is particularly the case if you are using mysql that connects to another database - You have to remember to reconnect the database back to your underlying Joomla mysql database, otherwise it has no way to connect back to your Joomla environment.
In any case, I wrote DirectPHP to run some simple PHP scripts. If you need to run complicated PHP scripts, would suggest you write a proper Joomla plugin or module. It's much cleaner and the codes are easier to debug.
Regards,
/kksou
script:
Work in standard PHP,
in DirectPHP have error
"Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /plugins/content/DirectPHP/DirectPHP.php(57) : eval()'d code on line 1"
if ($_GET["chronoform"]=="WybierzDate")
{
echo "{chronoforms}Li sta dni{/chronoforms}";
} else
{
echo "{chronoforms}Wy beierzDate{/chronoforms}";
}
1) Please try a simple one-liner PHP: echo "test123";
Just want to make sure that DirectPHP is running ok on your machine.
2) If (1) works, and you're sure that your codes above works fine in standard PHP, then the other possibilities is that the order of DirectPHP comes before that of your other plugin "chronoforms".
Please go to the Plugin Manager and see what's the order of DirectPHP and your other plugin chronoforms. If both are 0, please set DirectPHP to be 9, and chronoforms to be 10. If, say, the order of chronoforms is 3, then change the order of DirectPHP to be 2.
The key thing is: the order of DirectPHP must go BEFORE that of chronoforms - this will ensure that DirectPHP is processed first, followed by your chronoforms plugin.
Otherwise, if chronoforms is processed first, it will produce some codes which then go into DirectPHP - resulting in error because most likely chronoforms will not produce valid PHP codes.
Please give it a try again and let me know if it works.
Regards,
/kksou
"Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /plugins/content/DirectPHP/DirectPHP.php(59) : eval()'d code on line 1"
As the error message says, the error message is in the PHP code that you're trying to run.
Please refer to the following post for debugging tips: http://www.kksou.com/php-gtk2/index.php?option=com_fireboard&Itemid=67&func=view&id=4601&catid=16#4617
Regards,
/kksou
I installed the plug-in, enabled it, changed the SU setting to "No Filtering", but the expected results do not show.
The PHP code in my article is "
When I investigate why the expected output did not show, it is because there are HTML comment tags around the PHP code.
I did check to make sure that "Prepare content" was "Yes", as suggested on the Joomla forums.
Any ideas? Thanks...
less-than-character NOSPACE question-mark NOSPACE php SPACE echo SPACE "Hi."; SPACE question-mark NOSPACE greater-than-character
1) Did you see anything on the screen? Did you see the code?
2) When you enter the PHP codes in the article using the default Joomla editor, please make sure that you enter in the WYSIWYG mode. DO NOT use the HTML mode.
Regards,
/kksou
My next task is to get PHP code working that will output text as an image. My first attempt outputted the raw image data rather than the browser rendering an actual image.
I'm interested in using phpDirect, but I want to restrict the possibility of including php-code only for Super-User. It'S possible? In which way?
Greetings * Peter Winkels
Joomla does not have any access control for plugins and modules. So there's no way you can restrict the running of a plugin by users.
But if you know a bit of PHP and know how to retrieve the user id from within the Joomla framework, you can modify the source code of DirectPHP to achieve this.
Regards,
/kksou
I need to access to some virtuemart table directly....
echo 'abc'
comes out as 'abc' (no p-tags ...)
Any idea? Thank you!
Have you tried the tips as outlined in the article "How to enter HTML tags, javascript and PHP codes in Joomla 2.5?": http://www.kksou.com/php-gtk2/Joomla-Tips-Techniques/How-to-enter-HTML-tags-javascript-and-PHP-codes-in-Joomla-2.5.php
Regards,
/kksou
For what its worth:
1. I disable all the editors.
2. I use a php editor like notepad++ to get my php code working OUTSIDE of joomla. Once I know my code is really working, I paste it into a Joomla article.
Plug in works like a champ!
$business_name=$_POST['bus_name'];
....and so fort
$statement=$_POST['value3'];
$data =array();
foreach($_POST as $statement =>$value){
if (empty($value)) continue;
$data[$statemen t] =$value;
}
//insert to database
$sql="INSERT INTO statement (Bus_name, Name, Email, Phone, Total_Volume, Transaction, Statement_Fees )
VALUES ('$business_name','$name', '$email', '$phone','$total_volume','$transaction','$value')";
I notice all fields are inserted to the DB except Statement Fees it save as 0 even there's a value entered on the text field.
Can you help, Thanks! WebsiteD2
Why don't you put some debugging statement and see what's the value.
$data =array();
print_r($_POST) ;
foreach($_POST as $statement =>$value){
echo "statement($stat ement) value($value)";
if (empty($value)) continue;
$data[$statemen t] =$value;
}
Regards,
/kksou
1) What did you see on the screen? Are there any error messages?
2) Also, please go to the Plugin Manager and make sure that the order of DirectPHP comes before that of your plugin. e.g. if the order of your plugin is 10, make sure the order of DirectPHP is 8 or 9, or even 1. What this does is to make sure that DirectPHP is processed before your plugin.
Please give (2) a try and let me know if it works.
Regards,
/kksou
Thanks in advance
I have it working without a problem where the form's action goes to a PHP file that is not apart of a Joomla 2.5 article.
I'd like to make the PHP code inside an article, so that I retain all the same look.
In my form, I ask for the user's e-mail address. When submitted to a page with the (working) code that has the code inside a Joomla article, all I receive is this:
Parse error: syntax error, unexpected T_STRING in {directory_clip ped_for_privacy }/plugins/content/DirectPHP/DirectPHP.php(58) : eval()'d code on line 119
Any ideas?
Line 119 in my code is a } and it is in the proper position.
Line 58 in DirectPHP.php is... I don't know! haha
Please refer to the following article:
Using DirectPHP - intermixing PHP with HTML commands
http://www.kksou.com/php-gtk2/Joomla/Using-DirectPHP-intermixing-PHP-with-HTML-commands.php
Please make sure that you do not intermix PHP with HTML commands.
Regards,
/kksou
I'd like to have had all the code in my article, but that wouldn't work, so this is a good enough compromise. It gets the job done and now my app is almost done!
thank you for your plugin :)
I'm having a problem the plugin wont run a command which is not in the block list or maybe its the same as a blocked command its curl_init and curl_exec and curl_setopt i searched in the blocked list but cant find it any help?
thank you.
Does your PHP has the curl library installed? DirectPHP doesn't run it's own PHP. It runs on top of the PHP that runs with your Joomla. So if your original PHP does not have the curl library installed, those commands will also not run using DirectPHP.
If you're not sure, please do the following:
First create a .php file, in there put just
Load the file in your broswer.
Then check if your PHP has the curl library installed.
Regards,
/kksou
Most Joomla users will use the default Joomla visual editor to enter simple PHP codes into their article.
The default visual editor adds [br] to each shift-enter, and adds a pair of [p] and [/p] to each enter. These [br] and [p] tags will cause error when the PHP scripts are being processed by eval(). Hence all the [br] and [p] tags are removed before passing into eval().
If you know what you are doing, and you use some other editor that allows you to enter PHP/HTML codes directly into your article, then you can go to the Plugin Manager, click on DirectPHP, and in the parameter page, set "using_no_editor " to "Yes". The default is "No" which strips away all [br] and [p].
Regards,
/kksou
yes i have curl installed and running (i have a joomla 1.x running in another folder wich uses the same php script but in php module ) i thought if i used a php module instead that will make it work ?
thank you.
In that case, please turn on error_display in your php.ini.
Then put all your PHP scripts into a .php file somewhere on your server, and then using DirectPHP add:
Please let me know what's the error messages that you see on the screen.
Regards,
/kksou
The module installed fine and test out OK with some simple PHP. I'm now trying to see if I can integrate my WHMCS install into Joomla - WHMCS uses IONCube for protection.
Every time I copy & paste one of the .php files from my WHMCS install into DirectPHP I get the following error:
The file /var/www/html/[mydomain].com/plugins/content/DirectPHP/DirectPHP.php(58) : eval()'d code is corrupted.
It's cool if using IONcube protected code simply doesn't work with DirectPHP, I just wondered if you knew!
Thanks,
Steve
Can you elaborate a bit more what do you mean by "instead of the data itself"? And what's that Resource #122 (#121 etc.)? Can you please show the complete error message that you see on the screen?
Regards,
/kksou
Also, I'm running Joomla 2.5, database is thru PHPMyAdmin
I set all settings the way you explained it.
I use JCE and TinyMCE.
In JCE WYCIWYG Mode Joomla displays just the pure php code, in HTML Mode nothing appears.
IN MCE the PHP Part looks like this:
I use following line:
Could you write me an E-Mail, I could give you acces to see it. Thats strange!
lots of html code
open PHP tag
some code in an if else statement
curly brace to open the else clause
close the php tag
lots of html code
open the php tag
closing curly brace for the else clause
close the php tag again.
render this :
test
'; ?>
what's wrong ?
Joomla 1.5.26
no editor
Cannot see your code.
Please email me the code or send the code via the feedback form.
Regards,
/kksou
another try :
echo date('l j D, Y H:i:s');
echo 'test';
< ? php
echo date('l j D, Y H:i:s');
echo '< p >test< / p >';
? >
2) If you just put the first line
echo date('l j D, Y H:i:s');
what did you see on the screen?
Regards,
/kksou
2) with only date, nothing appear
in fact, it work well
i use the preview ... in the preview, it doesn't work ...
Wonderfull extension, I just have 1 question I keep getting a parse error eval() when i try to do the follow
$db =& JFactory::getDB O();
$query = "SELECT ....";
$result = $db->setQuery($query );
but it works fine when i omit the $result and use an echo.
How can i save that value into a variable?
Thanks
i have some problems, i have make a module with this included php:
In the Module is all fine, but if i insert this php string in a content site i got an error:
Warning: require_once(ho tel_preise/Prima_Life_Maka di_Resort.php) [function.require-once]: failed to open stream: No such file or directory in
Can you help me, please.
regards
You have to use the fullpath instead of relative path.
Regards,
/kksou
if iuse the fullpath i got a second error that in my server config is not allowed open urls.
Strange ist, i got this error after i click on save. but the content was saved, i can the it in the frontend.
all settings are changed to "no filtering".
i use the JCE Editor and joomla 2.5.7
regards
I have to display some custom serverside code for each contact on my Joomla 2.5 install. Do you think DirectPHP could do that?
I've tried without success, and I was wondering how hard you think your code was to tweak to achieve just that?
Thanks !
Thanks !
Its php+java+html
I use directPHP for long time. It is excellent. I only use normal code 1-2 lines. Please kindly suggest (which page to learn) for deep php. (Form, database)
Website http://krabihotelworld.com integrate travel affiliate program
environment
Joomla 2.5/editor Ace/404sef/
Thanks again
1) What did you see on the screen then? Did you see the original PHP code? Or you see nothing.
2) Are you using the default Joomla editor? If yes, please make sure you do not use the HTML mode. Please use the defualt WYSIWYG (What you see is what you get) mode to enter the code.
Regards,
/kksou
Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs \advancejoomla\ plugins\content \DirectPHP.php(54) : eval()'d code on line 9
May I know what's the code that you've used.
Also, please refer to the following article: How to debug PHP codes in DirectPHP
Please follow the instructions there. In (4) and (5), if you see any error or warning messages, please copy and paste it here so that I have more clues as to what might be the problem.
Regards,
/kksou
fullpath can u explain where is start fullpath???
Please google for "full path" and you can see many articles describing this.
Here's the one from wiki: wiki: Path (computing)
Regards,
/kksou
I tried to use it with JCE editor. This editor removes alle PHP code so this does not work.
CKEditor comments out all PHP code. I worked around this by changing the lines 41 and 42 in "directphp.php" as follows
$php_start = "" or "?>";
I can now use the plugin with a more sophisticated editor than tinymce.
I would like anyones comment on this.
(sorry I would have posted a picture if that were possible)
$php_start = "" or "?>" should be
$php_start = "comment+startPH Pcode" or "startphpcode"
$php_start = "endcomment+endp hp" or "endphp" (I hope you know what I mean) :)
I have no filtering set up.
any insight?
Just a few days ago, another user encounters similar thing. Turns out that there's another plugin that automatically comments out any scripts - both PHP and javascript.
Please check if there's any such plugin in your system.
To be sure, I would recommend that you install a fresh copy of Joomla somewhere else on your site, and then install just the DirectPHP plugin. This will allow you to see if the script works on your system at all.
Regards,
/kksou
Thanks
You might want to take a look at the article "How to debug PHP codes in DirectPHP" - Can DiectPHP runs all PHP codes?
The key thing is, DirectPHP is a Joomla plugin. As the name suggests, a plugin is run within a Joomla article.
What this means is that NOT ALL PHP scripts can be run within the Joomla framework.
For your case, would suggest you write a plugin, module or component in which your PHP codes will be run "native" within Joomla, instead of an additional layer.
Regards,
/kksou
Now the bad.. This extension appears to break Joomla 2.5's Smart Search. Pretty simple to verify - use DirectPHP to include some PHP on an article, then run Smart Search's Indexer. I haven't been able to make it work. Disable DirectPHP via plug-in manager and the Indexer works as expected - don't need to delete the code from the article, just disable the extension.
It's easy enough to disable/re-enable it, so not a deal breaker for me.. But would be a good fix!
Eep.. I'm using v1.7. maybe DirectPHP v2.5 fixed this?
Will this run on Joomla 3.0 and if not are you planning a new release?
Many thanks
Mark
I made it a point to support all Joomal versions. That's why you see there are versions all the way back to Joomla 1.0.
Problem is I've many projects at hand. Haven't got the time to play with Joomla 3.0 yet.
Will try to do it by end of this month.
Will send you a copy once it's ready, ok?
Warm Regards,
/kksou
parse error: syntax error, unexpected T_STRING in C:\xampp1.7.3\htdocs\susmita \nrss prtc\plugins\co ntent\DirectPHP \DirectPHP.php(58) : eval()'d code on line 8
can anyone tell me where i did d mistake;
Please refer to the article: How to debug PHP codes in DirectPHP
As DirectPHP uses the standard PHP eval() function, the error message you have given does not tell us anything.
You might want to list here what's PHP statement that you are trying to run. Otherwise it's very difficult for other people to help you without any further info.
Regards,
/kksou
i installed the plugin. It work' fine.
Now i try to code my content-page with some tables. therefor i use the html editor from TinyMCE.
Al my "php-Code" will be blocked like this:
"
If you need to add tables in HTML code using PHP's echo statement, you might want to try other editors like JCE Editor that allows you to enter the HTML codes in source mode.
Please also make sure that you set the appropriate setitngs in Joomla such that the HTML codes are not automatically stripped away by default.
Regards,
/kksou
Looking forward to the 3.0 version later on :)
Keep this up!
Pleased to tell you that I've just released the 3.0 version!
Download here: DirectPHP v3.0
Regards,
/kksou
Just to let you know that DirectPHP for Joomla 3.0 is now available.
You can download it here: DirectPHP v3.0
Regards,
/kksou
By removing "br" in the comment line or by removing the comment (//), the problem is resolved!!
example of the code
I want to embed a second php statement to call the current username to act as the filter in my sql WHERE statement in my query but the second php statement never got executed. Should I just use an intermediate php file and include it in the article or is there another way to code it directly in the article?
Multiple lines of codes should work right inside the article.
e.g. you can try
[?php
echo 'test1';
echo 'test2';
echo 'test3';
?]
note: please replace square brackets with angle brackets above
You should 'test1', 'test2' and 'test3' on the screen.
Regards,
/kksou
$user->
because it closes the
Any ideas?
That's really strange, because I'm using lots of -> on my site too.
Can you please do just a one liner and see if it works?
e.g. [?php $test = array('a'=>'test1'); echo $test->a; ?]
note: replace square brackets above with angle brackets.
Do you see 'test1' on the screen?
Regards,
/kksou
I have installed the directPHP in my Joomla 3 test site. And it works but I keep getting this message.
Notice: Undefined index: view in /var/www/html/joomla3/plugins/content/DirectPHP/DirectPHP.php(58) : eval()'d code on line 1
If you try just a one-liner: echo
[?php 'test123';?]
Think you will not get the error message.
This means that somewhere in your code produces this warning message.
Please refer to the article How to debug PHP codes in DirectPHP
Save your codes in a standalone .php file and debug from there. Once you've debug the code, you can then transfer the code back to your article.
Regards,
/kksou
Never Mind it was me ... my bad code.
Your plugin is very good.
I have a big problem on my site against.
on my pages php code is displayed, I do not know why.
how can I remove the PHP code so that it does not appear in the front-end.
everyone sees the code
Please help me it's urgent.
If the code displays, it usually means DirectPHP is not running.
Please check in the Plugins Manager that it's enabled.
Otherwise, please remove the code first and do the testing on some development machine or some remote article.
Regards,
/kksou
thank you for your quick response.
the plugin is enabled, I have tested this code, and it works: get ('mypg', null) if ($ fg == 'n') echo ('
Kjære språk-entusiast!
Det er å morsomt Laere and fremmed språk man heard nybegynner eller er litt OVET. Forutsetningen selvfølgelig følelsen av er noe å få igjen for innsatsen.
') Else echo ('
Dear language enthusiast!
Whether you are a beginner or know a bit Already, learning a foreign language is fun, as long, of course, as you feel you are reaping the rewards of your efforts.
')>
Read more ...
thank you for your quick response.
the plugin is enabled, I have tested this code, and it works:
hi
thank you for your quick response.
the plugin is enabled, I have tested this code, and it works: [php?
echo 'test1';
echo 'test2';
echo 'test3;
]
but I put my code, it does not work.
I do not understand because 1 week ago it worked well.
I made ??no changes
you have an idea.
J'utilse joomla 1.5.14
You said one week ago it worked well.
Now please try echo 'test123' again. Do you still see the code, or just 'test123'?
If you see the code, that means DirectPHP is not working. It might be conflicts with your other plugins or modules that you have just installed.
If you see 'test123', it means there's some error in the code. You may want to refer to the article: How to debug PHP codes in DirectPHP
Regards,
/kksou
I have always the same problem
I have not installed module or plugin.
I just look in the joomla administration and save to make a comeback.
My code works well elsewhere.
when I do echo "test123" I do not see that test123
here is the code that I put in a module
get('myfg', null); $pg = $session->get('mypg', null); if ($fg == 'n') echo('
and in another module I put
'); else echo ('
last module is
'); ?>;
I have a session english and another Norwegian.
do you think that there is an error in the code
Please refer to the article: How to debug PHP codes in DirectPHP
Please try to copy your code to a standalone .php file. Also turn on the display_errors in your php.ini file
You will then be able to see the actual error or warning messages.
Right now based on the information you've given here, it's very difficult to tell where might be the problem.
Regards,
/kksou
Inside an article, I open the PHP tag and can run PHP code no problem.
But if I try to echo a br tag, the br doesn't show/advance a blank line.
it's ok now
thanks you
good working
Failed to parse time string (jerror) at position 0 (j): The timezone could not be found in the database.
When will there be a 3.1.x version of DirectPHP?
The current version of DirectPHP works with the latest version of Joomla. I'm using it on my site.
1) Which PHP version are you using?
2) At which point does the error message occurs - during installation? I've never seen such an error before during installation.
Please provide more details so that I have more clues as to where might be the problem.
Regards,
/kksou
PHP version 5.3.3-7 + Squeeze3
Joomla 3.1.1 with dutch language package installed.
The site is hosted on Apache webserver using apache2handler
The exact error is:
DateTime::__con struct(): Failed to parse time string (jerror) at position 0 (j): The timezone could not be found in the database.
I've downloaded version v3.0 of PHPDirect, but inside the file DirectPHP.php comment stops at v2.5 Jan 25, 2012.
Or is the error the result of running DirectPHP with some of your PHP codes?
Regards,
/kksou
Yes, the error comes up while installing DirectPHP.
That's really strange, because I just tried installing it on a fresh install of Joomla and it worked fine.
If you have some time, would you mind do the same - i.e. try set up a fresh install of Joomla and then install DirectPHP. See if you get the same error.
This will allow us to see if DirectPHP works on your server at all, or if it's conflicts with some plugins.
Regards,
/kksou
I tried new installation on the same server
Get the same error.
On the same server I do have a joomla 2.5.8 site running DirectPHP realy fine.
You mentioned that you're using PHP version 5.3.3-7 + Squeeze3
Could it be because of this?
Do you have any other system that you can try? Just to want eliminate the possible root cause one by one.
Alternatively, there are other PHP plugins on joomla.org. Maybe one of them will work with your host.
Regards,
/kksou
I do not have an other server to do the test on different PHP versions.Thnx for your comment. Regards, Bert
RSS feed for comments to this post