AMuleWeb PHP

From AMule Project FAQ
Revision as of 16:00, 16 October 2006 by 199.203.130.250 (Talk)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

aMuleWeb PHP manual

By Froenchenko Leonid lfroen@gmail.com Lfroen

Introduction

aMuleWeb is an add-on program, used together with aMule and serves as webserver, allowing user to control aMule through browser interface. aMuleWeb works very similar to regular and wide-known webservers such as Apache[1] - set of HTML pages stored on server side (called "template"). Those pages contains embedded server-side script, which is running when user requests the page. Resulting page is returned to user.

The scripting language, aMuleWeb using is very similar to widely known "PHP", developed and distributed by Zend company [2]. Since aMuleWeb implementation is differ from original PHP, I will call it "aMuleWeb PHP" for reader convenience. "The PHP" language, will be referred as "real PHP" or just "PHP" to make difference between the two.

Conventions

Language elements, reserved words are marked bold: keyword.

Core language constructs

aMuleWeb PHP have same basic language elements as real PHP version 5. Several things supported or implemented differently: OO constructs (classes) may pass syntax check, but they are not supported in any way. include construct is parse-time directive (in contrary to PHP, where you can do it in run-time and check result of "include" operation) There's no list at all.

Variables

There's scalar (referred as $var) and array (referred as @var) variables. Similarly to real PHP all variables are local, unless defined otherwise. Variables, marked as global must be declated before this definition. Example:

$a = 1;
function foo()
{
	global $a;
}

References to variable and to array members are fully supported:

$a = &$b;
$c = &$c[5];
  • Notes:
    • Reference of variable by name like $$var is not supported.
    • Integer variables are 64-bit unsigned integers
    • Variable substitution inside of "" is not supported.


Predefined global variables

Similarly to real PHP, there's set of special, or predefined variables, which have special meaning. Those variables may indicate input received from user, or they may control script execution.

Operators

All PHP operators supported. Implicit type conversion is supported too, as common in scripting languages. This way 1 + "2" = 3. Arrays are converted to integer in "Perl style" i.e. in case array variable is used in integer context, number of members is taken as value.

  • Prefix and postfix ++ and -- are not distinguished (prefix form used)

Subroutines

function construct is fully supported. In contrary to regular PHP function must be defined prior calling. It is error to do otherwise. Functions can be recursive, thou. Real PHP allows to omit parameters for function calls (default parameters). aMuleWeb PHP does not support this conventions, which mean that all parameters must be present when function is called. This is not an error, and parameters will receive predefined values when omit: 0 for numbers, "" (empty string) for strings. Parameters can be references or arrays with usual meaning.

  • Function can return value but not reference.

Library

PHP language is known to have huge library of useful subroutines. Those subroutines are used to perform various tasks, varying from simple string manipulation to complex databases and OS binding. aMuleWeb PHP on the other hand, have very limited library. There's several reasons behind this fact. First of all, it is out of question to completely re-create PHP library, given it's size and complexity. Second, and most important, it's not really needed. aMuleWeb PHP is built to serve very specific application, and used to create very specific kind of pages. It will not be used to create e-commerce site or webmail. List below summarize supported functions:

  • var_dump($var): [3]
  • strlen($string):[4]
  • usort($var): [5]


aMule binding

The whole purpose of aMuleWeb control aMule. Script provide convinient way to access underlying aMule datastructure for both queries and actions.


Authentication

Real PHP have wide range of authentication and session management possibilities. In aMuleWeb PHP, status is different. Both authentication and session management are not part of scripting language. Instead, they are implemented as part of in webserver itself, and running invisibly for script engine.