diff --git a/lib/tablelib.php b/lib/tablelib.php
index ff5474a677e..e2da1e4257f 100644
--- a/lib/tablelib.php
+++ b/lib/tablelib.php
@@ -1,16 +1,49 @@
-.
+
+/**
+ * @package moodlecore
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+/** TABLE_VAR_SORT = 1 */
define('TABLE_VAR_SORT', 1);
+/** TABLE_VAR_HIDE = 2 */
define('TABLE_VAR_HIDE', 2);
+/** TABLE_VAR_SHOW = 3 */
define('TABLE_VAR_SHOW', 3);
+/** TABLE_VAR_IFIRST = 4 */
define('TABLE_VAR_IFIRST', 4);
+/** TABLE_VAR_ILAST = 5 */
define('TABLE_VAR_ILAST', 5);
+/** TABLE_VAR_PAGE = 6 */
define('TABLE_VAR_PAGE', 6);
+/** TABLE_P_TOP = 1 */
define('TABLE_P_TOP', 1);
+/** TABLE_P_BOTTOM = 2 */
define('TABLE_P_BOTTOM', 2);
-
+/**
+ * @package moodlecore
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class flexible_table {
var $uniqueid = NULL;
@@ -1140,6 +1173,11 @@ class flexible_table {
}
}
+/**
+ * @package moodlecore
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class table_sql extends flexible_table{
public $countsql = NULL;
@@ -1280,6 +1318,11 @@ class table_sql extends flexible_table{
}
}
+/**
+ * @package moodlecore
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class table_default_export_format_parent{
/**
* @var flexible_table or child class reference pointing to table class
@@ -1321,6 +1364,11 @@ class table_default_export_format_parent{
}
}
+/**
+ * @package moodlecore
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class table_spreadsheet_export_format_parent extends table_default_export_format_parent{
var $rownum;
var $workbook;
@@ -1391,6 +1439,11 @@ class table_spreadsheet_export_format_parent extends table_default_export_format
}
}
+/**
+ * @package moodlecore
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class table_excel_export_format extends table_spreadsheet_export_format_parent{
var $fileextension = 'xls';
@@ -1403,6 +1456,11 @@ class table_excel_export_format extends table_spreadsheet_export_format_parent{
}
+/**
+ * @package moodlecore
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class table_ods_export_format extends table_spreadsheet_export_format_parent{
var $fileextension = 'ods';
function define_workbook(){
@@ -1413,6 +1471,11 @@ class table_ods_export_format extends table_spreadsheet_export_format_parent{
}
}
+/**
+ * @package moodlecore
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class table_text_export_format_parent extends table_default_export_format_parent{
var $seperator = "\t";
function start_document($filename){
@@ -1442,16 +1505,31 @@ class table_text_export_format_parent extends table_default_export_format_parent
}
}
+/**
+ * @package moodlecore
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class table_tsv_export_format extends table_text_export_format_parent{
var $seperator = "\t";
}
+/**
+ * @package moodlecore
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class table_csv_export_format extends table_text_export_format_parent{
var $seperator = ",";
}
+/**
+ * @package moodlecore
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class table_xhtml_export_format extends table_default_export_format_parent{
function start_document($filename){
header("Content-Type: application/download\n");
diff --git a/lib/textlib.class.php b/lib/textlib.class.php
index 2d3222a0d8d..384973d428a 100644
--- a/lib/textlib.class.php
+++ b/lib/textlib.class.php
@@ -1,36 +1,36 @@
-.
-/// As we implement the singleton pattern to use this class (only one instance
-/// is shared globally), we need this helper function
-
-/// IMPORTANT Note: Typo3 libraries always expect lowercase charsets to use 100%
-/// its capabilities so, don't forget to make the conversion
-/// from every wrapper function!
+/**
+ * @package moodlecore
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+/**
+ * As we implement the singleton pattern to use this class (only one instance
+ * is shared globally), we need this helper function
+ *
+ * IMPORTANT Note: Typo3 libraries always expect lowercase charsets to use 100%
+ * its capabilities so, don't forget to make the conversion
+ * from every wrapper function!
+ *
+ * @global object
+ */
function textlib_get_instance() {
global $CFG;
@@ -92,6 +92,10 @@ function textlib_get_instance() {
* really a cool group of utilities to handle texts and encoding conversion.
*
* Take a look to its own copyright and license details.
+ *
+ * @package moodlecore
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class textlib {
diff --git a/lib/tokeniserlib.php b/lib/tokeniserlib.php
index a8ff4a7226a..a75a42a0885 100644
--- a/lib/tokeniserlib.php
+++ b/lib/tokeniserlib.php
@@ -1,48 +1,58 @@
-.
+//
-/// Based on Drupal's search.module version 1.224
-/// http://cvs.drupal.org/viewcvs/drupal/drupal/modules/search/search.module?view=markup
-
-/// Usage: $tokens = tokenise_text($text)
-/// Returns an array of tokens (key) with their score (value)
-/// (see function definition for more info)
-
-/// Some constants
+/**
+ * Based on Drupal's search.module version 1.224
+ *
+ * {@link http://cvs.drupal.org/viewcvs/drupal/drupal/modules/search/search.module?view=markup}
+ *
+ * Usage: $tokens = tokenise_text($text)
+ * Returns an array of tokens (key) with their score (value)
+ * (see function definition for more info)
+ *
+ * Major Contributors
+ * - Martin Dougiamas {@link http://moodle.com}
+ * - Eloy Lafuente (stronk7) {@link http://contiento.com}
+ * - Antonio Vicent {@link http://ludens.es}
+ *
+ * @package moodlecore
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+/**
+ * Some constants
+ */
define ('MINIMUM_WORD_SIZE', 3); /// Minimum word size to index and search
define ('MAXIMUM_WORD_SIZE', 50); /// Maximum word size to index and search
diff --git a/lib/upgradelib.php b/lib/upgradelib.php
index e7fbb826b35..4d7a76bee0c 100644
--- a/lib/upgradelib.php
+++ b/lib/upgradelib.php
@@ -24,12 +24,20 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
+/** UPGRADE_LOG_NORMAL = 0 */
define('UPGRADE_LOG_NORMAL', 0);
+/** UPGRADE_LOG_NOTICE = 1 */
define('UPGRADE_LOG_NOTICE', 1);
+/** UPGRADE_LOG_ERROR = 2 */
define('UPGRADE_LOG_ERROR', 2);
/**
* Exception indicating unknown error during upgrade.
+ *
+ * @package moodlecore
+ * @subpackage upgrade
+ * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class upgrade_exception extends moodle_exception {
function __construct($plugin, $version) {
@@ -41,6 +49,11 @@ class upgrade_exception extends moodle_exception {
/**
* Exception indicating downgrade error during upgrade.
+ *
+ * @package moodlecore
+ * @subpackage upgrade
+ * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class downgrade_exception extends moodle_exception {
function __construct($plugin, $oldversion, $newversion) {
@@ -51,6 +64,12 @@ class downgrade_exception extends moodle_exception {
}
}
+/**
+ * @package moodlecore
+ * @subpackage upgrade
+ * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class upgrade_requires_exception extends moodle_exception {
function __construct($plugin, $pluginversion, $currentmoodle, $requiremoodle) {
global $CFG;
@@ -63,6 +82,12 @@ class upgrade_requires_exception extends moodle_exception {
}
}
+/**
+ * @package moodlecore
+ * @subpackage upgrade
+ * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class plugin_defective_exception extends moodle_exception {
function __construct($plugin, $details) {
global $CFG;
@@ -74,6 +99,7 @@ class plugin_defective_exception extends moodle_exception {
* Insert or update log display entry. Entry may already exist.
* $module, $action must be unique
*
+ * @global object
* @param string $module
* @param string $action
* @param string $mtable
@@ -108,6 +134,7 @@ function update_log_display_entry($module, $action, $mtable, $field) {
* Please do not make large upgrade blocks with lots of operations,
* for example when adding tables keep only one table operation per block.
*
+ * @global object
* @param bool $result false if upgrade step failed, true if completed
* @param string or float $version main version
* @param bool $allowabort allow user to abort script execution here
@@ -142,6 +169,7 @@ function upgrade_main_savepoint($result, $version, $allowabort=true) {
* It stores module version, resets upgrade timeout
* and abort upgrade if user cancels page loading.
*
+ * @global object
* @param bool $result false if upgrade step failed, true if completed
* @param string or float $version main version
* @param string $modname name of module
@@ -181,6 +209,7 @@ function upgrade_mod_savepoint($result, $version, $modname, $allowabort=true) {
* It stores block version, resets upgrade timeout
* and abort upgrade if user cancels page loading.
*
+ * @global object
* @param bool $result false if upgrade step failed, true if completed
* @param string or float $version main version
* @param string $blockname name of block
@@ -256,7 +285,8 @@ function upgrade_plugin_savepoint($result, $version, $type, $dir, $allowabort=tr
/**
* Upgrade plugins
*
- * @uses $CFG
+ * @global object
+ * @global object
* @param string $type The type of plugins that should be updated (e.g. 'enrol', 'qtype')
* @param string $dir The directory where the plugins are located (e.g. 'question/questiontypes')
* @param string $return The url to prompt the user to continue to
@@ -359,6 +389,9 @@ function upgrade_plugins($type, $dir, $startcallback, $endcallback) {
/**
* Find and check all modules and load them up or upgrade them if necessary
+ *
+ * @global object
+ * @global object
*/
function upgrade_plugins_modules($startcallback, $endcallback) {
global $CFG, $DB;
@@ -460,6 +493,9 @@ function upgrade_plugins_modules($startcallback, $endcallback) {
/**
* This function finds all available blocks and install them
* into blocks table or do all the upgrade process if newer.
+ *
+ * @global object
+ * @global object
*/
function upgrade_plugins_blocks($startcallback, $endcallback) {
global $CFG, $DB;
@@ -604,7 +640,8 @@ function upgrade_plugins_blocks($startcallback, $endcallback) {
* in a file called 'local/db/upgrade.php', and if it's there calls it with the
* appropiate $oldversion parameter. Then it updates $CFG->local_version.
*
- * @uses $CFG
+ * @global object
+ * @global object
*/
function upgrade_local_db($startcallback, $endcallback) {
global $CFG, $DB;
@@ -655,9 +692,11 @@ function upgrade_local_db($startcallback, $endcallback) {
}
-////////////////////////////////////////////////
-/// upgrade logging functions
-////////////////////////////////////////////////
+/**
+ * upgrade logging functions
+ *
+ * @global object
+ */
function upgrade_handle_exception($ex, $plugin=null) {
global $CFG;
@@ -691,6 +730,9 @@ function upgrade_handle_exception($ex, $plugin=null) {
/**
* Adds log entry into upgrade_log table
*
+ * @global object
+ * @global object
+ * @global object
* @param int $type UPGRADE_LOG_NORMAL, UPGRADE_LOG_NOTICE or UPGRADE_LOG_ERROR
* @param string $plugin plugin or null if main
* @param string $info short description text of log entry
@@ -759,6 +801,10 @@ function upgrade_log($type, $plugin, $info, $details=null, $backtrace=null) {
/**
* Marks start of upgrade, blocks any other access to site.
* The upgrade is finished at the end of script or after timeout.
+ *
+ * @global object
+ * @global object
+ * @global object
*/
function upgrade_started($preinstall=false) {
global $CFG, $DB, $PAGE;
@@ -800,6 +846,9 @@ function upgrade_finished_handler() {
* Indicates upgrade is finished.
*
* This function may be called repeatedly.
+ *
+ * @global object
+ * @global object
*/
function upgrade_finished($continueurl=null) {
global $CFG, $DB;
@@ -816,6 +865,10 @@ function upgrade_finished($continueurl=null) {
}
}
+/**
+ * @global object
+ * @global object
+ */
function upgrade_setup_debug($starting) {
global $CFG, $DB;
@@ -833,6 +886,9 @@ function upgrade_setup_debug($starting) {
}
}
+/**
+ * @global object
+ */
function print_upgrade_reload($url) {
global $CFG;
@@ -948,6 +1004,9 @@ function silent_upgrade_part_end($plugin, $installation) {
}
}
+/**
+ * @global object
+ */
function upgrade_get_javascript() {
global $CFG;
return '';
@@ -956,6 +1015,7 @@ function upgrade_get_javascript() {
/**
* Try to upgrade the given language pack (or current language)
+ * @global object
*/
function upgrade_language_pack($lang='') {
global $CFG;
diff --git a/lib/uploadlib.php b/lib/uploadlib.php
index 3445c6bf414..738fe55e14c 100644
--- a/lib/uploadlib.php
+++ b/lib/uploadlib.php
@@ -1,19 +1,38 @@
.
+
/**
* uploadlib.php - This class handles all aspects of fileuploading
*
- * @author ?
- * @version $Id$
- * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
- * @package moodlecore
+ * @package moodlecore
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
+/** {@see eventslib.php} */
require_once($CFG->libdir.'/eventslib.php');
//error_reporting(E_ALL ^ E_NOTICE);
/**
* This class handles all aspects of fileuploading
+ *
+ * @package moodlecore
+ * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class upload_manager {
@@ -490,6 +509,7 @@ UPLOAD_PRINT_FORM_FRAGMENT DOESN'T REALLY BELONG IN THE CLASS BUT CERTAINLY IN T
/**
* This function prints out a number of upload form elements.
*
+ * @global object
* @param int $numfiles The number of elements required (optional, defaults to 1)
* @param array $names Array of element names to use (optional, defaults to FILE_n)
* @param array $descriptions Array of strings to be printed out before each file bit.
@@ -531,8 +551,8 @@ function upload_print_form_fragment($numfiles=1, $names=null, $descriptions=null
*
* If moving it fails, it deletes it.
*
- *@uses $CFG
- * @uses $USER
+ * @global object
+ * @global object
* @param string $file Full path to the file
* @param int $userid If not used, defaults to $USER->id (there in case called from cron)
* @param boolean $basiconly Admin level reporting or user level reporting.
@@ -597,6 +617,7 @@ function clam_handle_infected_file($file, $userid=0, $basiconly=false) {
*
* The replacement string is used to notify that the original file had a virus
* This is to avoid missing files but could result in the wrong content-type.
+ *
* @param string $file Full path to the file.
* @return boolean
*/
@@ -616,6 +637,9 @@ function clam_replace_infected_file($file) {
* If $CFG->runclamonupload is set, we scan a given file. (called from {@link preprocess_files()})
*
* This function will add on a uploadlog index in $file.
+ *
+ * @global object
+ * @global object
* @param mixed $file The file to scan from $files. or an absolute path to a file.
* @param course $course {@link $COURSE}
* @return int 1 if good, 0 if something goes wrong (opposite from actual error code from clam)
@@ -763,8 +787,8 @@ function get_clam_error_code($returncode) {
/**
* Adds a file upload to the log table so that clam can resolve the filename to the user later if necessary
*
- * @uses $CFG
- * @uses $USER
+ * @global object
+ * @global object
* @param string $newfilepath ?
* @param course $course {@link $COURSE}
* @param boolean $nourl ?
@@ -787,6 +811,7 @@ function clam_log_upload($newfilepath, $course=null, $nourl=false) {
/**
* This function logs to error_log and to the log table that an infected file has been found and what's happened to it.
*
+ * @global object
* @param string $oldfilepath Full path to the infected file before it was moved.
* @param string $newfilepath Full path to the infected file since it was moved to the quarantine directory (if the file was deleted, leave empty).
* @param int $userid The user id of the user who uploaded the file.
@@ -811,7 +836,7 @@ function clam_log_infected($oldfilepath='', $newfilepath='', $userid=0) {
/**
* Some of the modules allow moving attachments (glossary), in which case we need to hunt down an original log and change the path.
*
- * @uses $CFG
+ * @global object
* @param string $oldpath The old path to the file (should be in the log)
* @param string $newpath The new path to the file
* @param boolean $update If true this function will overwrite old record (used for forum moving etc).
diff --git a/lib/validateurlsyntax.php b/lib/validateurlsyntax.php
index f42e2914cd4..da201d4f093 100755
--- a/lib/validateurlsyntax.php
+++ b/lib/validateurlsyntax.php
@@ -1,172 +1,172 @@
.
-Usage:
- validateUrlSyntax( url_to_check[, options])
+/**
+ * About validateUrlSyntax():
+ * This function will verify if a http URL is formatted properly, returning
+ * either with true or false.
+ *
+ * I used rfc #2396 URI: Generic Syntax as my guide when creating the
+ * regular expression. For all the details see the comments below.
+ *
+ * Usage:
+ * validateUrlSyntax( url_to_check[, options])
+ *
+ * url_to_check - string - The url to check
+ *
+ * options - string - A optional string of options to set which parts of
+ * the url are required, optional, or not allowed. Each option
+ * must be followed by a "+" for required, "?" for optional, or
+ * "-" for not allowed.
+ *
+ * s - Scheme. Allows "+?-", defaults to "s?"
+ * H - http:// Allows "+?-", defaults to "H?"
+ * S - https:// (SSL). Allows "+?-", defaults to "S?"
+ * E - mailto: (email). Allows "+?-", defaults to "E-"
+ * F - ftp:// Allows "+?-", defaults to "F-"
+ * Dependant on scheme being enabled
+ * u - User section. Allows "+?-", defaults to "u?"
+ * P - Password in user section. Allows "+?-", defaults to "P?"
+ * Dependant on user section being enabled
+ * a - Address (ip or domain). Allows "+?-", defaults to "a+"
+ * I - Ip address. Allows "+?-", defaults to "I?"
+ * If I+, then domains are disabled
+ * If I-, then domains are required
+ * Dependant on address being enabled
+ * p - Port number. Allows "+?-", defaults to "p?"
+ * f - File path. Allows "+?-", defaults to "f?"
+ * q - Query section. Allows "+?-", defaults to "q?"
+ * r - Fragment (anchor). Allows "+?-", defaults to "r?"
+ *
+ * Paste the funtion code, or include_once() this template at the top of the page
+ * you wish to use this function.
+ *
+ *
+ * Examples:
+ *
+ * validateUrlSyntax('http://george@www.cnn.com/#top')
+ *
+ * validateUrlSyntax('https://games.yahoo.com:8080/board/chess.htm?move=true')
+ *
+ * validateUrlSyntax('http://www.hotmail.com/', 's+u-I-p-q-r-')
+ *
+ * validateUrlSyntax('/directory/file.php#top', 's-u-a-p-f+')
+ *
+ *
+ * if (validateUrlSyntax('http://www.canowhoopass.com/', 'u-'))
+ * {
+ * echo 'URL SYNTAX IS VERIFIED';
+ * } else {
+ * echo 'URL SYNTAX IS ILLEGAL';
+ * }
+ *
+ *
+ * Last Edited:
+ * December 15th 2004
+ *
+ *
+ * Changelog:
+ * December 15th 2004
+ * -Added new TLD's - .jobs, .mobi, .post and .travel. They are official, but not yet active.
+ *
+ * August 31th 2004
+ * -Fixed bug allowing empty username even when it was required
+ * -Changed and added a few options to add extra schemes
+ * -Added mailto: ftp:// and http:// options
+ * -https option was 'l' now it is 'S' (capital)
+ * -Added password option. Now passwords can be disabled while usernames are ok (for email)
+ * -IP Address option was 'i' now it is 'I' (capital)
+ * -Options are now case sensitive
+ * -Added validateEmailSyntax() and validateFtpSyntax() functions below
+ *
+ * August 27th, 2004
+ * -IP group range is more specific. Used to allow 0-299. Now it is 0-255
+ * -Port range more specific. Used to allow 0-69999. Now it is 0-65535
+ * -Fixed bug disallowing 'i-' option.
+ * -Changed license to GPL
+ *
+ * July 8th, 2004
+ * -Fixed bug disallowing 'l-' option. Thanks Dr. Cheap
+ *
+ * June 15, 2004
+ * -Added options parameter to make it easier for people to plug the function in
+ * without needed to rework the code.
+ * -Split the example application away from the function
+ *
+ * June 1, 2004
+ * -Complete rewrite
+ * -Now more modular
+ * -Easier to disable sections
+ * -Easier to port to other languages
+ * -Easier to port to verify email addresses
+ * -Uses only simple regular expressions so it is more portable
+ * -Follows RFC closer for domain names. Some "play" domains may break
+ * -Renamed from 'verifyUrl()' to 'validateUrlSyntax()'
+ * -Removed extra code which added 'http://' and trailing '/' if it was missing
+ * -That code was better suited for a massaging function, not verifying
+ * -Bug fixes:
+ * -Now splits up and forces '/path?query#fragment' order
+ * -No longer requires a path when using a query or fragment
+ *
+ * August 29, 2003
+ * -Allowed port numbers above 9999. Now allows up to 69999
+ *
+ * Sometime, 2002
+ * -Added new top level domains
+ * -aero, coop, museum, name, info, biz, pro
+ *
+ * October 5, 2000
+ * -First Version
+ *
+ *
+ * Intentional Limitations:
+ * -Does not verify url actually exists. Only validates the syntax
+ * -Strictly follows the RFC standards. Some urls exist in the wild which will
+ * not validate. Including ones with square brackets in the query section '[]'
+ *
+ *
+ * Known Problems:
+ * -None at this time
+ *
+ *
+ * Author(s):
+ * Rod Apeldoorn - rod(at)canowhoopass(dot)com
+ *
+ *
+ * Homepage:
+ * http://www.canowhoopass.com/
+ *
+ *
+ * Thanks!:
+ * -WEAV -Several members of Weav helped to test - http://weav.bc.ca/
+ * -There were also a number of emails from other developers expressing
+ * thanks and suggestions. It is nice to be appreciated. Thanks!
+ *
+ * Alternate Commercial Licenses:
+ * For information in regards to alternate licensing, contact me.
+ *
+ * @package moodlecore
+ * @copyright Copyright 2004, Rod Apeldoorn {@link http://www.canowhoopass.com/}
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
- url_to_check - string - The url to check
-
- options - string - A optional string of options to set which parts of
- the url are required, optional, or not allowed. Each option
- must be followed by a "+" for required, "?" for optional, or
- "-" for not allowed.
-
- s - Scheme. Allows "+?-", defaults to "s?"
- H - http:// Allows "+?-", defaults to "H?"
- S - https:// (SSL). Allows "+?-", defaults to "S?"
- E - mailto: (email). Allows "+?-", defaults to "E-"
- F - ftp:// Allows "+?-", defaults to "F-"
- Dependant on scheme being enabled
- u - User section. Allows "+?-", defaults to "u?"
- P - Password in user section. Allows "+?-", defaults to "P?"
- Dependant on user section being enabled
- a - Address (ip or domain). Allows "+?-", defaults to "a+"
- I - Ip address. Allows "+?-", defaults to "I?"
- If I+, then domains are disabled
- If I-, then domains are required
- Dependant on address being enabled
- p - Port number. Allows "+?-", defaults to "p?"
- f - File path. Allows "+?-", defaults to "f?"
- q - Query section. Allows "+?-", defaults to "q?"
- r - Fragment (anchor). Allows "+?-", defaults to "r?"
-
- Paste the funtion code, or include_once() this template at the top of the page
- you wish to use this function.
-
-
-Examples:
- validateUrlSyntax('http://george@www.cnn.com/#top')
-
- validateUrlSyntax('https://games.yahoo.com:8080/board/chess.htm?move=true')
-
- validateUrlSyntax('http://www.hotmail.com/', 's+u-I-p-q-r-')
-
- validateUrlSyntax('/directory/file.php#top', 's-u-a-p-f+')
-
-
- if (validateUrlSyntax('http://www.canowhoopass.com/', 'u-'))
- {
- echo 'URL SYNTAX IS VERIFIED';
- } else {
- echo 'URL SYNTAX IS ILLEGAL';
- }
-
-
-Last Edited:
- December 15th 2004
-
-
-Changelog:
- December 15th 2004
- -Added new TLD's - .jobs, .mobi, .post and .travel. They are official, but not yet active.
-
- August 31th 2004
- -Fixed bug allowing empty username even when it was required
- -Changed and added a few options to add extra schemes
- -Added mailto: ftp:// and http:// options
- -https option was 'l' now it is 'S' (capital)
- -Added password option. Now passwords can be disabled while usernames are ok (for email)
- -IP Address option was 'i' now it is 'I' (capital)
- -Options are now case sensitive
- -Added validateEmailSyntax() and validateFtpSyntax() functions below
-
- August 27th, 2004
- -IP group range is more specific. Used to allow 0-299. Now it is 0-255
- -Port range more specific. Used to allow 0-69999. Now it is 0-65535
- -Fixed bug disallowing 'i-' option.
- -Changed license to GPL
-
- July 8th, 2004
- -Fixed bug disallowing 'l-' option. Thanks Dr. Cheap
-
- June 15, 2004
- -Added options parameter to make it easier for people to plug the function in
- without needed to rework the code.
- -Split the example application away from the function
-
- June 1, 2004
- -Complete rewrite
- -Now more modular
- -Easier to disable sections
- -Easier to port to other languages
- -Easier to port to verify email addresses
- -Uses only simple regular expressions so it is more portable
- -Follows RFC closer for domain names. Some "play" domains may break
- -Renamed from 'verifyUrl()' to 'validateUrlSyntax()'
- -Removed extra code which added 'http://' and trailing '/' if it was missing
- -That code was better suited for a massaging function, not verifying
- -Bug fixes:
- -Now splits up and forces '/path?query#fragment' order
- -No longer requires a path when using a query or fragment
-
- August 29, 2003
- -Allowed port numbers above 9999. Now allows up to 69999
-
- Sometime, 2002
- -Added new top level domains
- -aero, coop, museum, name, info, biz, pro
-
- October 5, 2000
- -First Version
-
-
-Intentional Limitations:
- -Does not verify url actually exists. Only validates the syntax
- -Strictly follows the RFC standards. Some urls exist in the wild which will
- not validate. Including ones with square brackets in the query section '[]'
-
-
-Known Problems:
- -None at this time
-
-
-Author(s):
- Rod Apeldoorn - rod(at)canowhoopass(dot)com
-
-
-Homepage:
- http://www.canowhoopass.com/
-
-
-Thanks!:
- -WEAV -Several members of Weav helped to test - http://weav.bc.ca/
- -There were also a number of emails from other developers expressing
- thanks and suggestions. It is nice to be appreciated. Thanks!
-
-
-License:
- Copyright 2004, Rod Apeldoorn
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or (at
- your option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
- To view the license online, go to: http://www.gnu.org/copyleft/gpl.html
-
-
-Alternate Commercial Licenses:
- For information in regards to alternate licensing, contact me.
-*/
-
-
-// BEGINNING OF validateUrlSyntax() function
+/**
+ * BEGINNING OF validateUrlSyntax() function
+ */
function validateUrlSyntax( $urladdr, $options="" ){
// Force Options parameter to be lower case
@@ -328,51 +328,51 @@ function validateUrlSyntax( $urladdr, $options="" ){
-/*
-About ValidateEmailSyntax():
- This function uses the ValidateUrlSyntax() function to easily check the
- syntax of an email address. It accepts the same options as ValidateURLSyntax
- but defaults them for email addresses.
-
-
-Usage:
- validateEmailSyntax( url_to_check[, options])
-
- url_to_check - string - The url to check
-
- options - string - A optional string of options to set which parts of
- the url are required, optional, or not allowed. Each option
- must be followed by a "+" for required, "?" for optional, or
- "-" for not allowed. See ValidateUrlSyntax() docs for option list.
-
- The default options are changed to:
- s-H-S-E+F-u+P-a+I-p-f-q-r-
-
- This only allows an address of "name@domain".
-
-Examples:
- validateEmailSyntax('george@fakemail.com')
- validateEmailSyntax('mailto:george@fakemail.com', 's+')
- validateEmailSyntax('george@fakemail.com?subject=Hi%20George', 'q?')
- validateEmailSyntax('george@212.198.33.12', 'I?')
-
-
-
-Author(s):
- Rod Apeldoorn - rod(at)canowhoopass(dot)com
-
-
-Homepage:
- http://www.canowhoopass.com/
-
-
-License:
- Copyright 2004 - Rod Apeldoorn
-
- Released under same license as validateUrlSyntax(). For details, contact me.
-
-
-*/
+/**
+ * About ValidateEmailSyntax():
+ * This function uses the ValidateUrlSyntax() function to easily check the
+ * syntax of an email address. It accepts the same options as ValidateURLSyntax
+ * but defaults them for email addresses.
+ *
+ *
+ * Usage:
+ *
+ * validateEmailSyntax( url_to_check[, options])
+ *
+ * url_to_check - string - The url to check
+ *
+ * options - string - A optional string of options to set which parts of
+ * the url are required, optional, or not allowed. Each option
+ * must be followed by a "+" for required, "?" for optional, or
+ * "-" for not allowed. See ValidateUrlSyntax() docs for option list.
+ *
+ * The default options are changed to:
+ * s-H-S-E+F-u+P-a+I-p-f-q-r-
+ *
+ * This only allows an address of "name@domain".
+ *
+ * Examples:
+ *
+ * validateEmailSyntax('george@fakemail.com')
+ * validateEmailSyntax('mailto:george@fakemail.com', 's+')
+ * validateEmailSyntax('george@fakemail.com?subject=Hi%20George', 'q?')
+ * validateEmailSyntax('george@212.198.33.12', 'I?')
+ *
+ *
+ *
+ * Author(s):
+ * Rod Apeldoorn - rod(at)canowhoopass(dot)com
+ *
+ *
+ * Homepage:
+ * http://www.canowhoopass.com/
+ *
+ *
+ * License:
+ * Copyright 2004 - Rod Apeldoorn
+ *
+ * Released under same license as validateUrlSyntax(). For details, contact me.
+ */
function validateEmailSyntax( $emailaddr, $options="" ){
@@ -440,45 +440,47 @@ function validateEmailSyntax( $emailaddr, $options="" ){
-/*
-About ValidateFtpSyntax():
- This function uses the ValidateUrlSyntax() function to easily check the
- syntax of an FTP address. It accepts the same options as ValidateURLSyntax
- but defaults them for FTP addresses.
-
-
-Usage:
- validateFtpSyntax( url_to_check[, options])
-
- url_to_check - string - The url to check
-
- options - string - A optional string of options to set which parts of
- the url are required, optional, or not allowed. Each option
- must be followed by a "+" for required, "?" for optional, or
- "-" for not allowed. See ValidateUrlSyntax() docs for option list.
-
- The default options are changed to:
- s?H-S-E-F+u?P?a+I?p?f?q-r-
-
-Examples:
- validateFtpSyntax('ftp://netscape.com')
- validateFtpSyntax('moz:iesucks@netscape.com')
- validateFtpSyntax('ftp://netscape.com:2121/browsers/ns7/', 'u-')
-
-
-Author(s):
- Rod Apeldoorn - rod(at)canowhoopass(dot)com
-
-
-Homepage:
- http://www.canowhoopass.com/
-
-
-License:
- Copyright 2004 - Rod Apeldoorn
-
- Released under same license as validateUrlSyntax(). For details, contact me.
-*/
+/**
+ * About ValidateFtpSyntax():
+ * This function uses the ValidateUrlSyntax() function to easily check the
+ * syntax of an FTP address. It accepts the same options as ValidateURLSyntax
+ * but defaults them for FTP addresses.
+ *
+ *
+ * Usage:
+ *
+ * validateFtpSyntax( url_to_check[, options])
+ *
+ * url_to_check - string - The url to check
+ *
+ * options - string - A optional string of options to set which parts of
+ * the url are required, optional, or not allowed. Each option
+ * must be followed by a "+" for required, "?" for optional, or
+ * "-" for not allowed. See ValidateUrlSyntax() docs for option list.
+ *
+ * The default options are changed to:
+ * s?H-S-E-F+u?P?a+I?p?f?q-r-
+ *
+ * Examples:
+ *
+ * validateFtpSyntax('ftp://netscape.com')
+ * validateFtpSyntax('moz:iesucks@netscape.com')
+ * validateFtpSyntax('ftp://netscape.com:2121/browsers/ns7/', 'u-')
+ *
+ *
+ * Author(s):
+ * Rod Apeldoorn - rod(at)canowhoopass(dot)com
+ *
+ *
+ * Homepage:
+ * http://www.canowhoopass.com/
+ *
+ *
+ * License:
+ * Copyright 2004 - Rod Apeldoorn
+ *
+ * Released under same license as validateUrlSyntax(). For details, contact me.
+ */
function validateFtpSyntax( $ftpaddr, $options="" ){