! Fix many of the phpdocumentor errors with our docblock's
Many files, many to go ! fun fun fun, don't miss out Signed-off-by: Spuds <spuds@simplemachines.org>
| @@ -1,7 +1,19 @@ | ||
| <?php | ||
| /** | ||
| - * | ||
| * Simple Machines Forum (SMF) | ||
| + * | ||
| + * @package SMF | ||
| + * @author Simple Machines http://www.simplemachines.org | ||
| + * @copyright 2012 Simple Machines | ||
| + * @license http://www.simplemachines.org/about/smf/license.php BSD | ||
| + * | ||
| + * @version 2.1 Alpha 1 | ||
| + */ | ||
| + | ||
| +if (!defined('SMF')) | ||
| + die('Hacking attempt...'); | ||
| + | ||
| +/** | ||
| * Simple cURL class to fetch a web page | ||
| * Properly redirects even with safe mode and basedir restrictions | ||
| * Can provide simple post options to a page | ||
| @@ -23,20 +35,14 @@ | ||
| * - $fetch_data->result(); // an array of results, body, header, http result codes | ||
| * - $fetch_data->result_raw(); // show all results of all calls (in the event of a redirect) | ||
| * - $fetch_data->result_raw(0); // show all results of call x | ||
| - * | ||
| - * @package SMF | ||
| - * @author Simple Machines http://www.simplemachines.org | ||
| - * @copyright 2012 Simple Machines | ||
| - * @license http://www.simplemachines.org/about/smf/license.php BSD | ||
| - * | ||
| - * @version 2.1 Alpha 1 | ||
| */ | ||
| - | ||
| -if (!defined('SMF')) | ||
| - die('Hacking attempt...'); | ||
| - | ||
| class curl_fetch_web_data | ||
| { | ||
| + /** | ||
| + * Set the default itmes for this class | ||
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
|
||
| + * | ||
| + * @var type | ||
| + */ | ||
| private $default_options = array( | ||
| CURLOPT_RETURNTRANSFER => 1, // Get returned value as a string (don't output it) | ||
| CURLOPT_HEADER => 1, // We need the headers to do our own redirect | ||
| @@ -55,8 +61,8 @@ class curl_fetch_web_data | ||
| * Start the curl object | ||
| * - allow for user override values | ||
| * | ||
| - * @param type $options, cURL options as an array | ||
| - * @param type $max_redirect, use to overide the default of 3 | ||
| + * @param type $options cURL options as an array | ||
| + * @param type $max_redirect use to overide the default of 3 | ||
| */ | ||
| public function __construct($options = array(), $max_redirect = 3) | ||
| { | ||
| @@ -72,8 +78,8 @@ public function __construct($options = array(), $max_redirect = 3) | ||
| * - passed arrays will be converted to a post string joined with &'s | ||
| * - calls set_options to set the curl opts array values based on the defaults and user input | ||
| * | ||
| - * @param type $url, the site we are going to fetch | ||
| - * @param type $post_data, any post data as form name => value | ||
| + * @param type $url the site we are going to fetch | ||
| + * @param type $post_data any post data as form name => value | ||
| */ | ||
| public function get_url_data($url, $post_data = array()) | ||
| { | ||
| @@ -95,8 +101,8 @@ public function get_url_data($url, $post_data = array()) | ||
| * - stores responses (url, code, error, headers, body) in the response array | ||
| * - detects 301, 302, 307 codes and will redirect to the given response header location | ||
| * | ||
| - * @param type $url, site to fetch | ||
| - * @param type $redirect, flag to indicate if this was a redirect request or not | ||
| + * @param type $url site to fetch | ||
| + * @param type $redirect flag to indicate if this was a redirect request or not | ||
| * @return boolean | ||
| */ | ||
| private function curl_request($url, $redirect = false) | ||
| @@ -151,8 +157,8 @@ private function curl_request($url, $redirect = false) | ||
| /** | ||
| * Used if being redirected to ensure we have a fully qualified address | ||
| * | ||
| - * @param type $last_url, where we went to | ||
| - * @param type $new_url, where we were redirected to | ||
| + * @param type $last_url where we went to | ||
| + * @param type $new_url where we were redirected to | ||
| * @return new url location | ||
| */ | ||
| private function get_redirect_url($last_url = '', $new_url = '') | ||
| @@ -176,7 +182,7 @@ private function get_redirect_url($last_url = '', $new_url = '') | ||
| * - called as ->result() will return the full final array | ||
| * - called as ->result('body') to just return the page source of the result | ||
| * | ||
| - * @param type $area, used to return an area such as body, header, error | ||
| + * @param type $area used to return an area such as body, header, error | ||
| * @return type | ||
| */ | ||
| public function result($area = '') | ||
| @@ -21,19 +21,33 @@ | ||
| */ | ||
| class xmlArray | ||
| { | ||
| - // The array and debugging output level. | ||
| - public $array, $debug_level, $trim; | ||
| + /** | ||
| + * holds xml parsed results | ||
| + * @var array | ||
| + */ | ||
| + public $array; | ||
| + | ||
| + /** | ||
| + * holds debugging level | ||
| + * @var type | ||
| + */ | ||
| + public $debug_level; | ||
| + | ||
| + /** | ||
| + * holds trim level textual data | ||
| + * @var bool | ||
| + */ | ||
| + public $trim; | ||
| /** | ||
| * Constructor for the xml parser. | ||
| * Example use: | ||
| * $xml = new xmlArray(file('data.xml')); | ||
| + * | ||
| * @param string $data the xml data or an array of, unless is_clone is true. | ||
| - * @param bool $auto_trim, default false, used to automatically trim textual data. | ||
| - * @param int $level, default null, the debug level, specifies whether notices | ||
| - * should be generated for missing elements and attributes. | ||
| - * @param bool $is_clone, default false. If is_clone is true, the | ||
| - * xmlArray is cloned from another - used internally only. | ||
| + * @param bool $auto_trim default false, used to automatically trim textual data. | ||
| + * @param int $level default null, the debug level, specifies whether notices should be generated for missing elements and attributes. | ||
| + * @param bool $is_clone default false. If is_clone is true, the xmlArray is cloned from another - used internally only. | ||
| */ | ||
| public function __construct($data, $auto_trim = false, $level = null, $is_clone = false) | ||
| { | ||
| @@ -179,8 +193,9 @@ public function path($path, $return_full = false) | ||
| * Check if an element exists. | ||
| * Example use, | ||
| * echo $xml->exists('html/body') ? 'y' : 'n'; | ||
| + * | ||
| * @param string $path - the path to the element to get. | ||
| - * @return bool | ||
| + * @return boolean | ||
|
joshuaadickerson
added a note
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
|
||
| */ | ||
| public function exists($path) | ||
| { | ||
| @@ -298,7 +313,8 @@ public function create_xml($path = null) | ||
| * Output the xml in an array form. | ||
| * Example use: | ||
| * print_r($xml->to_array()); | ||
| - * @param string $path, the path to output. | ||
| + * | ||
| + * @param string $path the path to output. | ||
| */ | ||
| public function to_array($path = null) | ||
| { | ||
| @@ -322,6 +338,7 @@ public function to_array($path = null) | ||
| /** | ||
| * Parse data into an array. (privately used...) | ||
| + * | ||
| * @param string $data to parse | ||
| */ | ||
| protected function _parse($data) | ||
| @@ -469,6 +486,7 @@ protected function _parse($data) | ||
| /** | ||
| * Get a specific element's xml. (privately used...) | ||
| + * | ||
| * @param $array | ||
| * @param $indent | ||
| */ | ||
| @@ -519,7 +537,12 @@ protected function _xml($array, $indent) | ||
| return $output; | ||
| } | ||
| - // Return an element as an array... | ||
| + /** | ||
| + * Return an element as an array | ||
| + * | ||
| + * @param type $array | ||
| + * @return type | ||
| + */ | ||
| protected function _array($array) | ||
| { | ||
| $return = array(); | ||
| @@ -543,6 +566,7 @@ protected function _array($array) | ||
| /** | ||
| * Parse out CDATA tags. (htmlspecialchars them...) | ||
| + * | ||
| * @param $data | ||
| */ | ||
| function _to_cdata($data) | ||
| @@ -579,6 +603,7 @@ function _to_cdata($data) | ||
| /** | ||
| * Turn the CDATAs back to normal text. | ||
| + * | ||
| * @param $data | ||
| */ | ||
| protected function _from_cdata($data) | ||
| @@ -624,6 +649,7 @@ protected function _fetch($array) | ||
| /** | ||
| * Get a specific array by path, one level down. (privately used...) | ||
| + * | ||
| * @param array $array | ||
| * @param string $path | ||
| * @param int $level | ||
| @@ -686,13 +712,43 @@ protected function _path($array, $path, $level, $no_error = false) | ||
| /** | ||
| * Simple FTP protocol implementation. | ||
| + * | ||
| * http://www.faqs.org/rfcs/rfc959.html | ||
| */ | ||
| class ftp_connection | ||
| { | ||
| - public $connection, $error, $last_message, $pasv; | ||
| + /** | ||
| + * holds the connection response | ||
| + * @var type | ||
| + */ | ||
| + public $connection; | ||
| - // Create a new FTP connection... | ||
| + /** | ||
| + * holds any errors | ||
| + * @var type | ||
| + */ | ||
| + public $error; | ||
| + | ||
| + /** | ||
| + * holds last message from the server | ||
| + * @var type | ||
| + */ | ||
| + public $last_message; | ||
| + | ||
| + /** | ||
| + * Passive connection | ||
| + * @var type | ||
| + */ | ||
| + public $pasv; | ||
| + | ||
| + /** | ||
| + * Create a new FTP connection... | ||
| + * | ||
| + * @param type $ftp_server | ||
| + * @param type $ftp_port | ||
| + * @param type $ftp_user | ||
| + * @param type $ftp_pass | ||
| + */ | ||
| public function __construct($ftp_server, $ftp_port = 21, $ftp_user = 'anonymous', $ftp_pass = 'ftpclient@simplemachines.org') | ||
| { | ||
| // Initialize variables. | ||
| @@ -704,6 +760,15 @@ public function __construct($ftp_server, $ftp_port = 21, $ftp_user = 'anonymous' | ||
| $this->connect($ftp_server, $ftp_port, $ftp_user, $ftp_pass); | ||
| } | ||
| + /** | ||
| + * Connects to a server | ||
| + * | ||
| + * @param type $ftp_server | ||
| + * @param type $ftp_port | ||
| + * @param type $ftp_user | ||
| + * @param type $ftp_pass | ||
| + * @return type | ||
| + */ | ||
| public function connect($ftp_server, $ftp_port = 21, $ftp_user = 'anonymous', $ftp_pass = 'ftpclient@simplemachines.org') | ||
| { | ||
| if (strpos($ftp_server, 'ftp://') === 0) | ||
| @@ -746,6 +811,12 @@ public function connect($ftp_server, $ftp_port = 21, $ftp_user = 'anonymous', $f | ||
| } | ||
| } | ||
| + /** | ||
| + * Changes to a directory (chdir) via the ftp connection | ||
| + * | ||
| + * @param type $ftp_path | ||
| + * @return boolean | ||
| + */ | ||
| public function chdir($ftp_path) | ||
| { | ||
| if (!is_resource($this->connection)) | ||
| @@ -765,6 +836,13 @@ public function chdir($ftp_path) | ||
| return true; | ||
| } | ||
| + /** | ||
| + * Changes a files atrributes (chmod) | ||
| + * | ||
| + * @param string $ftp_file | ||
| + * @param type $chmod | ||
| + * @return boolean | ||
| + */ | ||
| public function chmod($ftp_file, $chmod) | ||
| { | ||
| if (!is_resource($this->connection)) | ||
| @@ -784,6 +862,12 @@ public function chmod($ftp_file, $chmod) | ||
| return true; | ||
| } | ||
| + /** | ||
| + * Deletes a file | ||
| + * | ||
| + * @param type $ftp_file | ||
| + * @return boolean | ||
| + */ | ||
| public function unlink($ftp_file) | ||
| { | ||
| // We are actually connected, right? | ||
| @@ -807,6 +891,12 @@ public function unlink($ftp_file) | ||
| return true; | ||
| } | ||
| + /** | ||
| + * Reads the response to the command from the server | ||
| + * | ||
| + * @param type $desired | ||
| + * @return type | ||
| + */ | ||
| public function check_response($desired) | ||
| { | ||
| // Wait for a response that isn't continued with -, but don't wait too long. | ||
| @@ -819,6 +909,11 @@ public function check_response($desired) | ||
| return is_array($desired) ? in_array(substr($this->last_message, 0, 3), $desired) : substr($this->last_message, 0, 3) == $desired; | ||
| } | ||
| + /** | ||
| + * Used to create a passive connection | ||
| + * | ||
| + * @return boolean | ||
| + */ | ||
| public function passive() | ||
| { | ||
| // We can't create a passive data connection without a primary one first being there. | ||
| @@ -852,6 +947,12 @@ public function passive() | ||
| return true; | ||
| } | ||
| + /** | ||
| + * Creates a new file on the server | ||
| + * | ||
| + * @param type $ftp_file | ||
| + * @return boolean | ||
| + */ | ||
| public function create_file($ftp_file) | ||
| { | ||
| // First, we have to be connected... very important. | ||
| @@ -885,6 +986,13 @@ public function create_file($ftp_file) | ||
| return true; | ||
| } | ||
| + /** | ||
| + * Generates a direcotry listing for the current directory | ||
| + * | ||
| + * @param type $ftp_path | ||
| + * @param type $search | ||
| + * @return boolean | ||
| + */ | ||
| public function list_dir($ftp_path = '', $search = false) | ||
| { | ||
| // Are we even connected...? | ||
| @@ -923,6 +1031,13 @@ public function list_dir($ftp_path = '', $search = false) | ||
| return $data; | ||
| } | ||
| + /** | ||
| + * Determins the current dirctory we are in | ||
| + * | ||
| + * @param type $file | ||
| + * @param type $listing | ||
| + * @return string|boolean | ||
| + */ | ||
| public function locate($file, $listing = null) | ||
| { | ||
| if ($listing === null) | ||
| @@ -963,6 +1078,12 @@ public function locate($file, $listing = null) | ||
| return false; | ||
| } | ||
| + /** | ||
| + * Creates a new directory on the server | ||
| + * | ||
| + * @param type $ftp_dir | ||
| + * @return boolean | ||
| + */ | ||
| public function create_dir($ftp_dir) | ||
| { | ||
| // We must be connected to the server to do something. | ||
| @@ -980,6 +1101,13 @@ public function create_dir($ftp_dir) | ||
| return true; | ||
| } | ||
| + /** | ||
| + * Detects the current path | ||
| + * | ||
| + * @param type $filesystem_path | ||
| + * @param type $lookup_file | ||
| + * @return type | ||
| + */ | ||
| public function detect_path($filesystem_path, $lookup_file = null) | ||
| { | ||
| $username = ''; | ||
| @@ -1025,6 +1153,11 @@ public function detect_path($filesystem_path, $lookup_file = null) | ||
| return array($username, $path, isset($found_path)); | ||
| } | ||
| + /** | ||
| + * Close the ftp connection | ||
| + * | ||
| + * @return boolean | ||
| + */ | ||
| public function close() | ||
| { | ||
| // Goodbye! | ||
| @@ -557,7 +557,7 @@ function BrowseFiles() | ||
| * @param int $start | ||
| * @param int $items_per_page | ||
| * @param string $sort | ||
| - * @param string $browse_type, can be 'avatars' or ... not. :P | ||
| + * @param string $browse_type can be on eof 'avatars' or ... not. :P | ||
|
joshuaadickerson
added a note
"one of" misspelled.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
|
||
| */ | ||
| function list_getFiles($start, $items_per_page, $sort, $browse_type) | ||
| { | ||
| @@ -616,8 +616,7 @@ function list_getFiles($start, $items_per_page, $sort, $browse_type) | ||
| * Return the number of files of the specified type recorded in the database. | ||
| * (the specified type being attachments or avatars). | ||
| * | ||
| - * @param string $browse_type, can be 'avatars' or not. (in which case they're | ||
| - * attachments) | ||
| + * @param string $browse_type can be one of 'avatars' or not. (in which case they're attachments) | ||
| */ | ||
| function list_getNumFiles($browse_type) | ||
| { | ||
| @@ -2578,6 +2577,9 @@ function attachDirStatus($dir, $expected_files) | ||
| return array('ok', false, $num_files); | ||
| } | ||
| +/** | ||
| + * Maintance function to move attachments from one directory to another | ||
| + */ | ||
| function TransferAttachments() | ||
| { | ||
| global $modSettings, $context, $smcFunc, $sourcedir, $txt, $boarddir; | ||
Just a note - items is misspelled.