Bevey Develop
If you're looking to do development on Bevey, there are a few built-in functions you should be aware of. All functions are found inside the inc/ directory:
-
cacher.php
- cacher
- Accepts a resource owner userid, resource type, resource id and optional feed type and begins or ends caching for that particular resource. This function returns the values of "startcache", "endcache", "oldcache", "readcache" and "notcaching" - whose corresponding functions should be obvious. If the return value of "startcache" is returned, the function expects to be called again to end the caching. If "readcache" is returned, the contents of the cache are displayed - thus, the non-cached script should not be echoed. Examples of how to put a simple if statement around a code block can be found in photos.php.
-
captcha.php
- captcha
- No parameters are accepted. Returns an array with the values of:
- 0 - Output text of the captcha phrase
- 1 - The expected format of the captcha result, hashed via SHA1 and the admin generated captcha key. This is reasonably safe to set as a hidden field to a form.
-
checkbanned.php
- checkbanned
- Accepts a userid (if available) and checks both that userid and the user's IP address to see if they are banned. Returns TRUE if banned, otherwise returns FALSE.
-
checkemail.php
- checkemail
- Accepts an email address and checks if that address has any remaining registrations available (as defined in the settings.php). If maximum number of registrations has been reached, it will return TRUE. If additional registrations are available or if there is an error (such as an invalid email address being passed), FALSE is returned.
-
checkiffriend.php
- checkiffriend
- Accepts the userids of the user (initiator of the potential friendship) and the userid of the potential friend. If the first user has the second user marked as a friend, TRUE will be returned. Otherwise, FALSE will be returned.
-
dbserver.php
- serverconnect
- Accepts a defined system code (see below as to how they are formatted). Returns the opened connection to the MySQL server. If an error occurs, the error code will be displayed and page process will die.
- serverquery
- Accepts a pre-formatted query string and a defined system code (see below as to how they are formatted). Returns the raw MySQL results. If an error occurs, the error code will be displayed and page process will die.
-
findtags.php
- findtags
- Accepts the page owner's userid, the resource id being viewed and the resource type ('a' for about pages, 'b' for blog posts and 'p' for photo pages). Returns an array (index of zero) of the corresponding tags.
-
finduserinfo.php
- finduserinfo
- Accepts a userid (or username) and the type of info being requested. Be aware that this function caches it's results. The benefit is that queries for common elements (userid, status, etc) are nearly free. The downside is that if this information is altered and is needed later in the page, it will return the cached result - which will no longer be valid. If you expect data to be altered, consider writing a custom query instead of calling this function. The following info types are available:
- username
- status (as a single character - 'a' for admin, 't' for trusted user, 'u' for user, 'p' for unverified user, 'b' for banned user).
- skin (as a numeric reference to the current skin selected - 0 for no skin, 1 for default skin, 2+ are in reference to skinX.css as defined in the settings.php).
- password (only the sha1 hash of the password is returned).
- ip (the last IP address the user had accessed the system with).
- about (the full body text of their main user page)
- messagecount (unread only)
- photocount
- blogcount
- commentcount
- postcount (the sum of postcount and commentcount)
- friends (returns an array of all userid's of the user's friends)
- modules (returns an array of all modulenames the user has activated)
- galleries (returns a two dimensional array of 0 - gallery ids and 1 - gallery titles)
- userid (returns the userid of the username passed - this is the only parameter that will accept username instead of userid).
- photo
-
parser.php
- parser
- Accepts the pre-formatted text body and returns converted HTML and BBCode to sanitized, proper XHTML for output.
-
sanitize.php
- sanitize
- Accepts the pre-formatted text, type of text (these correspond directly to the database column names they are either being written to or drawn from), source of text ('user' or 'db') and database connection (if applicable). Returns the cleaned string, ready for display or writing to a database.
-
showicon.php
- showicon
- Accepts the userid and username of a potential friend (in relation to the user that is logged in). If the user is a friend, a string is returned with the properly formatted icon. If the user is not a friend, a string is returned with a link to add this user as a friend along with the properly formatted icon.
-
sniffer.php
- sniffer
- Accepts either 'ie6' or 'ie7'. If 'ie6' is defined, TRUE will be returned for all browsers the viewer is using that are IE6 or below. If 'ie7' is defined, TRUE will be returned only for IE7.
-
stringcheck.php
- stringcheck
- Accepts a string of text to be tested as well as the type of string it is ('username', 'email', 'name', 'date'). If the string is invalid, TRUE is returned. If the string is "clean", FALSE is returned. This function differs from sanitize in that it only checks the validity of a string - it does not return a modified version of it.
-
timedate.php
- timedate
- Accepts the raw date (as stored in the MySQL database) and returns the formatted string equivalent - ready for printing.
System Codes
All database connection calls, database queries and file system references have corresponding error codes for easy debugging and presenting the user with a non-technical summary of the problem that had occurred. Error codes are formatted as follows:
- All modules are prefixed with 'M-'
- All included functions are prefixed with 'I-'
- All pages are then prefixed with an acronym of the file they are in. For 'checkiffriend.php', the error code prefix would be 'I-CIF'.
- For database connection calls, the error number will start with a 1.
- For a database query, the error number will start with a 2.
- For a filesystem reference, the error number will start with a 3.
- The last two numbers of the error code start with 00 and incriment by 1.
- For a module named 'usertags', with the third query in document will have the error code 'M-UT203'
Module Development
If you're interested in developing your own modules, you may find working from an existing module helpful. Additionally, a nonsensical example module has been created for you to use as reference.
