Code: Select all
$config['use_smarty_php_tags'] = true;
the folowing code works perfectly on a simple php file.
But using it in UDT or the {php}{/php} combo produces nothing and unpredictable results.
Code: Select all
function GetExt($name)
{
$ext = strrchr($name, '.');
if($ext !== false)
{
$ext = substr($ext, 1);
}
return $ext;
}
function showDir($folder, $allowed_extensions ) {
$d = dir($folder);
//echo "Handle: " . $d->handle . "<br/>\n";
echo "<H2>Path: " . $d->path . "</H2><br/>\n";
$x = 0;
while (false !== ($entry = $d->read())) {
if(is_file($entry)) {
//echo GetExt($entry)."<br/>\n";
if( in_array(GetExt($entry), $allowed_extensions) ) {
$x++;
echo "<TR><TD>$x.</TD><TD><A HREF='$entry'>$entry</A></TD><TD>???</TD></TR>\n";
}
}
}
$d->close();
}
$DIRROOT = "/home/user/www/blahblah";
$allowed_extensions = array("pdf","gif", "jpg", "jpeg");
echo $DIRROOT.'<BR>';
$folder = $DIRROOT.'/test';
//echo $folder. '<BR>';
echo "<TABLE border=1>\n";
showDir($folder, $allowed_extensions);
echo "</TABLE>\n";
and alsoYou can use any valid php code in a user defined tag, including the "include" command to include external scripts.
After changing some lines I tried not using my functions and not using the is_file and in_array functions calls... it worked but not as i want which is to display only files with specific extensions of a given subdir.Change the "use_smarty_php_tags" setting to true. ... Now you can place php code into your page or template at will.
What other option is there in CMSms for inserting php code?
CMSms molokai -> linux env. -> hosted (safe mode ON)
I'm using PHP Version 5.2.1 and MySQL 4.1.21 on Apache/1.3.37