=head1 bbBoard v2 ExtLang - Make source code modifications in other languages =head1 What is ExtLang? The ExtLang backend allows you to make modifications to the Perl source code of bbBoard v2 in a range of different languages. So if you don't know Perl, you can still hack away to your heart's content. =head1 C Using C requires the "Inline" and "Inline::C" Perl modules to be installed. You can install these if needed by clicking on "Perl Modules" in your Admin Panel. Here's an example of how to use C code in bbBoard v2's Perl scripts. use Inline (C => 'DATA', DIRECTORY => 'lib'); $ret .= some_c_function(5); [...] # At the bottom of the script __DATA__ __C__ int some_c_function(int value) { return (value * 2); } Note that you have to put the __DATA__ (and everything after it) at the I bottom of the script, whereas the "use" section should go where you need to use the C function. The Inline::C module allows you to very easily interact with C functions in this way. The C code will be compiled on the first page load, so there may be a short pause the first time the code is run. For more information, you may also want to take a look at the Inline::C documentation, available at: f, which includes information on including headers, linking against specific libraries etc. =head1 PHP =head2 PHP Setup The PHP ExtLang requires a small amount of setup/configuration before you can use it. First of all, your PHP must be built with the "--enable-embed=shared" configure option. For example: ./configure --enable-embed=shared When your PHP is built with the above option, telnet or SSH into your server, and cd to the directory you installed bbBoard v2 in. Then type: cd Backend/ExtLang Log in to your client area, and download the Extlang::PHP extension. Upload the .tgz file (exactly as it is - you don't need to decompress it) to the Backend/ExtLang directory. Then, go back to your command prompt and type: ./insphp Provided you have a working /bin/sh, this will then install the ExtLang::PHP backend for you. You can then use PHP in the bbBoard v2 scripts! =head2 PHP Use The PHP ExtLang is slightly different to the others. Here's an example of it's use in one of bbBoard v2's Perl scripts. use Backend::ExtLang::PHP; $ret .= bbphp q{ echo "Hello!\n"; // More PHP code here }; All you need to change in the above is the PHP code! Here's a slightly different invocation, giving you user information provided in the environment for you to make use of in your PHP code. use Backend::ExtLang::PHP; $ret .= bbphp $self, q{ echo "Username of person currently logged in is: "; echo $_ENV[BB_USERNAME]; echo "
User ID of person currently logged in is: "; echo $_ENV[BB_ID]; echo "
Email of person currently logged in is: "; echo $_ENV[BB_EMAIL]; echo "
Time zone offset of person currently logged in is: "; echo $_ENV[BB_TIMEZONE]; echo "
Whether the current user is anonymous or not: "; if ($_ENV[BB_ANONYMOUS] == 1) { echo "Yes"; } else { echo "No"; } echo "
Post count of person currently logged in is: "; echo $_ENV[BB_POSTCOUNT]; // etc }; Note that if you want to be able to use the BB_ $_ENV variables in your PHP code, you must include the $self as in the example above: [...] $ret .= bbphp $self, q{ [...] }; Here's a slightly more practical example: use Backend::ExtLang::PHP; $ret .= bbphp $self, q{ if ($_ENV[BB_USERNAME]) { echo "Your username is: " . $_ENV[BB_USERNAME]; if (eregi("Jim",$_ENV[BB_USERNAME])) { echo " Hi Jim!"; } } else { echo "You're not logged in!"; } }; As you can see, you can do just about anything you can do in normal PHP. =head1 Others There are many different languages you can use within bbBoard v2 scripts. They are mostly available from the Inline series of modules, which are available at L. Unfortunately, we cannot provide support for the installation or use of these modules, as they are written by many different people.