|
@@ -22,7 +22,8 @@ if (!defined('SMF'))
|
|
|
/**
|
|
|
* Reads a .tar.gz file, filename, in and extracts file(s) from it.
|
|
|
* essentially just a shortcut for read_tgz_data().
|
|
|
- * @param string $filename
|
|
|
+ *
|
|
|
+ * @param string $gzfilename
|
|
|
* @param string $destination
|
|
|
* @param bool $single_file = false
|
|
|
* @param bool $overwrite = false
|
|
@@ -225,7 +226,16 @@ function read_tgz_data($data, $destination, $single_file = false, $overwrite = f
|
|
|
return $return;
|
|
|
}
|
|
|
|
|
|
-// Extract zip data. If destination is null, return a listing.
|
|
|
+/**
|
|
|
+ * Extract zip data. If destination is null, return a listing.
|
|
|
+ *
|
|
|
+ * @param type $data
|
|
|
+ * @param type $destination
|
|
|
+ * @param type $single_file
|
|
|
+ * @param type $overwrite
|
|
|
+ * @param type $files_to_extract
|
|
|
+ * @return boolean
|
|
|
+ */
|
|
|
function read_zip_data($data, $destination, $single_file = false, $overwrite = false, $files_to_extract = null)
|
|
|
{
|
|
|
umask(0);
|
|
@@ -342,7 +352,7 @@ function read_zip_data($data, $destination, $single_file = false, $overwrite = f
|
|
|
* Checks the existence of a remote file since file_exists() does not do remote.
|
|
|
* will return false if the file is "moved permanently" or similar.
|
|
|
* @param string url
|
|
|
- * @return bool true if the remote url exists.
|
|
|
+ * @return boolean true if the remote url exists.
|
|
|
*/
|
|
|
function url_exists($url)
|
|
|
{
|
|
@@ -432,7 +442,7 @@ function loadInstalledPackages()
|
|
|
* - otherwise returns a basic array of id, version, filename, and similar information.
|
|
|
* - an xmlArray is available in 'xml'.
|
|
|
*
|
|
|
- * @param string $filename
|
|
|
+ * @param string $gzfilename
|
|
|
* @return array
|
|
|
*/
|
|
|
function getPackageInfo($gzfilename)
|
|
@@ -487,7 +497,14 @@ function getPackageInfo($gzfilename)
|
|
|
return $package;
|
|
|
}
|
|
|
|
|
|
-// Create a chmod control for chmoding files.
|
|
|
+/**
|
|
|
+ * Create a chmod control for chmoding files.
|
|
|
+ *
|
|
|
+ * @param type $chmodFiles
|
|
|
+ * @param type $chmodOptions
|
|
|
+ * @param type $restore_write_status
|
|
|
+ * @return boolean
|
|
|
+ */
|
|
|
function create_chmod_control($chmodFiles = array(), $chmodOptions = array(), $restore_write_status = false)
|
|
|
{
|
|
|
global $context, $modSettings, $package_ftp, $boarddir, $txt, $sourcedir, $scripturl;
|
|
@@ -495,6 +512,15 @@ function create_chmod_control($chmodFiles = array(), $chmodOptions = array(), $r
|
|
|
// If we're restoring the status of existing files prepare the data.
|
|
|
if ($restore_write_status && isset($_SESSION['pack_ftp']) && !empty($_SESSION['pack_ftp']['original_perms']))
|
|
|
{
|
|
|
+ /**
|
|
|
+ * Get a listing of files that will need to be set back to the original state
|
|
|
+ *
|
|
|
+ * @param type $dummy1
|
|
|
+ * @param type $dummy2
|
|
|
+ * @param type $dummy3
|
|
|
+ * @param type $do_change
|
|
|
+ * @return type
|
|
|
+ */
|
|
|
function list_restoreFiles($dummy1, $dummy2, $dummy3, $do_change)
|
|
|
{
|
|
|
global $txt;
|
|
@@ -793,6 +819,8 @@ function create_chmod_control($chmodFiles = array(), $chmodOptions = array(), $r
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Use FTP functions to work with a package download/install
|
|
|
+ *
|
|
|
* @param string $destination_url
|
|
|
* @param array $files = none
|
|
|
* @param bool $return = false
|
|
@@ -1442,6 +1470,8 @@ function parsePackageInfo(&$packageXML, $testing_only = true, $method = 'install
|
|
|
* - returns true if the version matched.
|
|
|
*
|
|
|
* @param string $versions
|
|
|
+ * @param boolean $reset
|
|
|
+ * @param type $the_version
|
|
|
* @return highest install value string or false
|
|
|
*/
|
|
|
function matchHighestPackageVersion($versions, $reset = false, $the_version)
|
|
@@ -1481,7 +1511,7 @@ function matchHighestPackageVersion($versions, $reset = false, $the_version)
|
|
|
*
|
|
|
* @param string $version
|
|
|
* @param string $versions
|
|
|
- * @return bool
|
|
|
+ * @return boolean
|
|
|
*/
|
|
|
function matchPackageVersion($version, $versions)
|
|
|
{
|
|
@@ -1582,6 +1612,7 @@ function compareVersions($version1, $version2)
|
|
|
|
|
|
/**
|
|
|
* Parses special identifiers out of the specified path.
|
|
|
+ *
|
|
|
* @param string $path
|
|
|
* @return string The parsed path
|
|
|
*/
|
|
@@ -1617,8 +1648,9 @@ function parse_path($path)
|
|
|
/**
|
|
|
* Deletes a directory, and all the files and direcories inside it.
|
|
|
* requires access to delete these files.
|
|
|
- * @param string $path
|
|
|
- * @param bool $delete_directory = true
|
|
|
+ *
|
|
|
+ * @param string $dir
|
|
|
+ * @param bool $delete_dir = true
|
|
|
*/
|
|
|
function deltree($dir, $delete_dir = true)
|
|
|
{
|
|
@@ -1692,9 +1724,10 @@ function deltree($dir, $delete_dir = true)
|
|
|
/**
|
|
|
* Creates the specified tree structure with the mode specified.
|
|
|
* creates every directory in path until it finds one that already exists.
|
|
|
- * @param string $path
|
|
|
+ *
|
|
|
+ * @param string $strPath
|
|
|
* @param int $mode
|
|
|
- * @return bool true if successful, false otherwise
|
|
|
+ * @return boolean true if successful, false otherwise
|
|
|
*/
|
|
|
function mktree($strPath, $mode)
|
|
|
{
|
|
@@ -1761,6 +1794,7 @@ function mktree($strPath, $mode)
|
|
|
/**
|
|
|
* Copies one directory structure over to another.
|
|
|
* requires the destination to be writable.
|
|
|
+ *
|
|
|
* @param string $source
|
|
|
* @param string $destination
|
|
|
*/
|
|
@@ -1807,6 +1841,8 @@ function copytree($source, $destination)
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Create a tree listing for a given directory path
|
|
|
+ *
|
|
|
* @param string $path
|
|
|
* @param string $sub_path = ''
|
|
|
* @return array
|
|
@@ -1839,6 +1875,7 @@ function listtree($path, $sub_path = '')
|
|
|
|
|
|
/**
|
|
|
* Parses a xml-style modification file (file).
|
|
|
+ *
|
|
|
* @param string $file
|
|
|
* @param bool $testing = true tells it the modifications shouldn't actually be saved.
|
|
|
* @param bool $undo = false specifies that the modifications the file requests should be undone; this doesn't work with everything (regular expressions.)
|
|
@@ -2534,6 +2571,12 @@ function parseBoardMod($file, $testing = true, $undo = false, $theme_paths = arr
|
|
|
return $actions;
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * Get the physical contents of a packages file
|
|
|
+ *
|
|
|
+ * @param type $filename
|
|
|
+ * @return boolean
|
|
|
+ */
|
|
|
function package_get_contents($filename)
|
|
|
{
|
|
|
global $package_cache, $modSettings;
|
|
@@ -2561,8 +2604,10 @@ function package_get_contents($filename)
|
|
|
* uses FTP to create/chmod the file when necessary and available.
|
|
|
* uses text mode for text mode file extensions.
|
|
|
* returns the number of bytes written.
|
|
|
+ *
|
|
|
* @param string $filename
|
|
|
* @param string $data
|
|
|
+ * @param bool testing
|
|
|
* @return int
|
|
|
*/
|
|
|
function package_put_contents($filename, $data, $testing = false)
|
|
@@ -2618,6 +2663,12 @@ function package_put_contents($filename, $data, $testing = false)
|
|
|
return strlen($data);
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * Clears (removes the files) the current package cache (temp directory)
|
|
|
+ *
|
|
|
+ * @param type $trash
|
|
|
+ * @return type
|
|
|
+ */
|
|
|
function package_flush_cache($trash = false)
|
|
|
{
|
|
|
global $package_ftp, $package_cache;
|
|
@@ -2676,7 +2727,7 @@ function package_flush_cache($trash = false)
|
|
|
* @param string $filename
|
|
|
* @param string $perm_state = 'writable'
|
|
|
* @param bool $track_change = false
|
|
|
- * @return bool True if it worked, false if it didn't
|
|
|
+ * @return boolean True if it worked, false if it didn't
|
|
|
*/
|
|
|
function package_chmod($filename, $perm_state = 'writable', $track_change = false)
|
|
|
{
|
|
@@ -3135,10 +3186,15 @@ function fetch_web_data($url, $post_data = '', $keep_alive = false, $redirection
|
|
|
return $data;
|
|
|
}
|
|
|
|
|
|
-// crc32 doesn't work as expected on 64-bit functions - make our own.
|
|
|
-// http://www.php.net/crc32#79567
|
|
|
if (!function_exists('smf_crc32'))
|
|
|
{
|
|
|
+ /**
|
|
|
+ * crc32 doesn't work as expected on 64-bit functions - make our own.
|
|
|
+ * http://www.php.net/crc32#79567
|
|
|
+ *
|
|
|
+ * @param type $number
|
|
|
+ * @return type
|
|
|
+ */
|
|
|
function smf_crc32($number)
|
|
|
{
|
|
|
$crc = crc32($number);
|