### Start of Variables ### ## Version that lives in Frogdown directory # Variables that start with "_" are template variables # If found, the leading "_" will be removed. # They are used to match "%%Variable%% template variables in # template pieces in the configuration files. # _PageTitle is used in the Page Header template. # i.e. %%PageTitle%% etc. _PageTitle = Some PHP code # _PageID isn't used yet. But it will be--make sure that every page has a unique _PageID. _PageID = Some_PHP # Force all images to be created? # (Usually only needed when you are fiddling with image sizes.) # Or if you are experimenting with ImageMagickConfig in the config files ForceImageCreation = 0 # Put assorted config variables as comments at the start of the output file. # Probably should only be used while debugging. Debug = 0 # Also generate a word wrapped version of this file? # Only is needed if you want to make this file available on the site. # MakeTextFile = 1 # If using any PHP code, we will want the file extension to be 'php' # not 'html' So... HTMLFileExt = .php ### End of Variables ### (This page `SomePHP.md` was last edited on %attr SomePHP.md|dt%) This is a demo of a few bits of embedded PHP. Do `Ctl-U` to view source code and try to find any .php code. (Hint, there isn't because PHP code is executed on the web server before it gets to you.) But look at the Frogdown source code: %l SomePHP.text|SomePHP.text% (which is really a copy of `SomePHP.md`) to see the embedded PHP code. You can also examine `SomePHP.php` with nano in your web server's `DocumentRoot` directory. At this point the web server hasn't executed the PHP code. First a quick validity test that PHP works. %save%This was printed by PHP. "; $Filename = "Frogdown.zip"; // for a bit later // Variables are better than hard-wired data. print "Still in PHP. The PHP code defined a PHP \$Filename variable that is defined as: $Filename

\n"; ?>%/save% Now we are out of PHP and back in regular HTML. Now we'll use a PHP function to find when $Filename"; ?> was last modified. (Actually the preceding sentence went into PHP to print the value of the `$Filename` variable. Which isn't a variable in regular HTML. You don't need to break out `\%save\%` for short inline PHP code. Only for longer multi-like PHP that has blank lines.) %save%$Filename was last modified (zipped) on " . file_mod_date($Filename,7) . "

\n"; print "

This page (SomePHP.php) was last modified (generated) on " . file_mod_date("SomePHP.php",7) . "

\n"; ?>%/save% `SomePHP.php` was *generated* by Frogdown so it will (probably) have a different modification date than `SomePHP.md` (which was modified (edited) on %attr SomePHP.md|dt%)) Then we'll use PHP to find out how large $Filename"; ?> is. %save%$Filename is " . file_size($Filename) . " long.

\n"; ?>%/save% And we are back to regular HTML. %save% New! "; $mtime = $new . " " . $mtime; //$mtime .= " (" . date("d")-$new . " days old)"; } // $mtime .= " (" . file_size($fname) . " bytes)"; } return $mtime; } // Returns a file's size function file_size($fname) { $decade=""; $size = "Can't determine file size."; //$size = $fname; if (file_exists($fname)) { $size = filesize($fname); if ($size >= 1048576) { $size = number_format( ($size/1048576) , 1 ) . " megabytes"; } else if ($size >= 1024 ) { $size = number_format( ($size/1024) , 0 ) . " kilobytes"; } else { $size = number_format($size) . " bytes"; } } return $size; } ?> %/save%