Edit File by line
/home/barbar84/www/wp-conte.../plugins/worker/src/PHPSecLi.../Net
File: SFTP.php
return false;
[2000] Fix | Delete
}
[2001] Fix | Delete
[2002] Fix | Delete
extract(unpack('Nstatus', $this->_string_shift($response, 4)));
[2003] Fix | Delete
if ($status != NET_SFTP_STATUS_OK) {
[2004] Fix | Delete
$this->_logError($response, $status);
[2005] Fix | Delete
break;
[2006] Fix | Delete
}
[2007] Fix | Delete
}
[2008] Fix | Delete
[2009] Fix | Delete
return $i < 0;
[2010] Fix | Delete
}
[2011] Fix | Delete
[2012] Fix | Delete
/**
[2013] Fix | Delete
* Close handle
[2014] Fix | Delete
*
[2015] Fix | Delete
* @param String $handle
[2016] Fix | Delete
*
[2017] Fix | Delete
* @return Boolean
[2018] Fix | Delete
* @access private
[2019] Fix | Delete
*/
[2020] Fix | Delete
public function _close_handle($handle)
[2021] Fix | Delete
{
[2022] Fix | Delete
if (!$this->_send_sftp_packet(NET_SFTP_CLOSE, pack('Na*', strlen($handle), $handle))) {
[2023] Fix | Delete
return false;
[2024] Fix | Delete
}
[2025] Fix | Delete
[2026] Fix | Delete
// "The client MUST release all resources associated with the handle regardless of the status."
[2027] Fix | Delete
// -- http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-8.1.3
[2028] Fix | Delete
$response = $this->_get_sftp_packet();
[2029] Fix | Delete
if ($this->packet_type != NET_SFTP_STATUS) {
[2030] Fix | Delete
user_error('Expected SSH_FXP_STATUS');
[2031] Fix | Delete
[2032] Fix | Delete
return false;
[2033] Fix | Delete
}
[2034] Fix | Delete
[2035] Fix | Delete
extract(unpack('Nstatus', $this->_string_shift($response, 4)));
[2036] Fix | Delete
if ($status != NET_SFTP_STATUS_OK) {
[2037] Fix | Delete
$this->_logError($response, $status);
[2038] Fix | Delete
[2039] Fix | Delete
return false;
[2040] Fix | Delete
}
[2041] Fix | Delete
[2042] Fix | Delete
return true;
[2043] Fix | Delete
}
[2044] Fix | Delete
[2045] Fix | Delete
/**
[2046] Fix | Delete
* Downloads a file from the SFTP server.
[2047] Fix | Delete
*
[2048] Fix | Delete
* Returns a string containing the contents of $remote_file if $local_file is left undefined or a boolean false if
[2049] Fix | Delete
* the operation was unsuccessful. If $local_file is defined, returns true or false depending on the success of the
[2050] Fix | Delete
* operation.
[2051] Fix | Delete
*
[2052] Fix | Delete
* $offset and $length can be used to download files in chunks.
[2053] Fix | Delete
*
[2054] Fix | Delete
* @param String $remote_file
[2055] Fix | Delete
* @param optional String $local_file
[2056] Fix | Delete
* @param optional Integer $offset
[2057] Fix | Delete
* @param optional Integer $length
[2058] Fix | Delete
*
[2059] Fix | Delete
* @return Mixed
[2060] Fix | Delete
* @access public
[2061] Fix | Delete
*/
[2062] Fix | Delete
public function get($remote_file, $local_file = false, $offset = 0, $length = -1)
[2063] Fix | Delete
{
[2064] Fix | Delete
if (!($this->bitmap & NET_SSH2_MASK_LOGIN)) {
[2065] Fix | Delete
return false;
[2066] Fix | Delete
}
[2067] Fix | Delete
[2068] Fix | Delete
$remote_file = $this->_realpath($remote_file);
[2069] Fix | Delete
if ($remote_file === false) {
[2070] Fix | Delete
return false;
[2071] Fix | Delete
}
[2072] Fix | Delete
[2073] Fix | Delete
$packet = pack('Na*N2', strlen($remote_file), $remote_file, NET_SFTP_OPEN_READ, 0);
[2074] Fix | Delete
if (!$this->_send_sftp_packet(NET_SFTP_OPEN, $packet)) {
[2075] Fix | Delete
return false;
[2076] Fix | Delete
}
[2077] Fix | Delete
[2078] Fix | Delete
$response = $this->_get_sftp_packet();
[2079] Fix | Delete
switch ($this->packet_type) {
[2080] Fix | Delete
case NET_SFTP_HANDLE:
[2081] Fix | Delete
$handle = substr($response, 4);
[2082] Fix | Delete
break;
[2083] Fix | Delete
case NET_SFTP_STATUS: // presumably SSH_FX_NO_SUCH_FILE or SSH_FX_PERMISSION_DENIED
[2084] Fix | Delete
$this->_logError($response);
[2085] Fix | Delete
[2086] Fix | Delete
return false;
[2087] Fix | Delete
default:
[2088] Fix | Delete
user_error('Expected SSH_FXP_HANDLE or SSH_FXP_STATUS');
[2089] Fix | Delete
[2090] Fix | Delete
return false;
[2091] Fix | Delete
}
[2092] Fix | Delete
[2093] Fix | Delete
if ($local_file !== false) {
[2094] Fix | Delete
$fp = fopen($local_file, 'wb');
[2095] Fix | Delete
if (!$fp) {
[2096] Fix | Delete
return false;
[2097] Fix | Delete
}
[2098] Fix | Delete
} else {
[2099] Fix | Delete
$content = '';
[2100] Fix | Delete
}
[2101] Fix | Delete
[2102] Fix | Delete
$start = $offset;
[2103] Fix | Delete
$size = $this->max_sftp_packet < $length || $length < 0 ? $this->max_sftp_packet : $length;
[2104] Fix | Delete
while (true) {
[2105] Fix | Delete
$packet = pack('Na*N3', strlen($handle), $handle, $offset / 4294967296, $offset, $size);
[2106] Fix | Delete
if (!$this->_send_sftp_packet(NET_SFTP_READ, $packet)) {
[2107] Fix | Delete
if ($local_file !== false) {
[2108] Fix | Delete
fclose($fp);
[2109] Fix | Delete
}
[2110] Fix | Delete
[2111] Fix | Delete
return false;
[2112] Fix | Delete
}
[2113] Fix | Delete
[2114] Fix | Delete
$response = $this->_get_sftp_packet();
[2115] Fix | Delete
switch ($this->packet_type) {
[2116] Fix | Delete
case NET_SFTP_DATA:
[2117] Fix | Delete
$temp = substr($response, 4);
[2118] Fix | Delete
$offset += strlen($temp);
[2119] Fix | Delete
if ($local_file === false) {
[2120] Fix | Delete
$content .= $temp;
[2121] Fix | Delete
} else {
[2122] Fix | Delete
fputs($fp, $temp);
[2123] Fix | Delete
}
[2124] Fix | Delete
break;
[2125] Fix | Delete
case NET_SFTP_STATUS:
[2126] Fix | Delete
// could, in theory, return false if !strlen($content) but we'll hold off for the time being
[2127] Fix | Delete
$this->_logError($response);
[2128] Fix | Delete
break 2;
[2129] Fix | Delete
default:
[2130] Fix | Delete
user_error('Expected SSH_FXP_DATA or SSH_FXP_STATUS');
[2131] Fix | Delete
if ($local_file !== false) {
[2132] Fix | Delete
fclose($fp);
[2133] Fix | Delete
}
[2134] Fix | Delete
[2135] Fix | Delete
return false;
[2136] Fix | Delete
}
[2137] Fix | Delete
[2138] Fix | Delete
if ($length > 0 && $length <= $offset - $start) {
[2139] Fix | Delete
break;
[2140] Fix | Delete
}
[2141] Fix | Delete
}
[2142] Fix | Delete
[2143] Fix | Delete
if ($length > 0 && $length <= $offset - $start) {
[2144] Fix | Delete
if ($local_file === false) {
[2145] Fix | Delete
$content = substr($content, 0, $length);
[2146] Fix | Delete
} else {
[2147] Fix | Delete
ftruncate($fp, $length);
[2148] Fix | Delete
}
[2149] Fix | Delete
}
[2150] Fix | Delete
[2151] Fix | Delete
if ($local_file !== false) {
[2152] Fix | Delete
fclose($fp);
[2153] Fix | Delete
}
[2154] Fix | Delete
[2155] Fix | Delete
if (!$this->_close_handle($handle)) {
[2156] Fix | Delete
return false;
[2157] Fix | Delete
}
[2158] Fix | Delete
[2159] Fix | Delete
// if $content isn't set that means a file was written to
[2160] Fix | Delete
return isset($content) ? $content : true;
[2161] Fix | Delete
}
[2162] Fix | Delete
[2163] Fix | Delete
/**
[2164] Fix | Delete
* Deletes a file on the SFTP server.
[2165] Fix | Delete
*
[2166] Fix | Delete
* @param String $path
[2167] Fix | Delete
* @param Boolean $recursive
[2168] Fix | Delete
*
[2169] Fix | Delete
* @return Boolean
[2170] Fix | Delete
* @access public
[2171] Fix | Delete
*/
[2172] Fix | Delete
public function delete($path, $recursive = true)
[2173] Fix | Delete
{
[2174] Fix | Delete
if (!($this->bitmap & NET_SSH2_MASK_LOGIN)) {
[2175] Fix | Delete
return false;
[2176] Fix | Delete
}
[2177] Fix | Delete
[2178] Fix | Delete
$path = $this->_realpath($path);
[2179] Fix | Delete
if ($path === false) {
[2180] Fix | Delete
return false;
[2181] Fix | Delete
}
[2182] Fix | Delete
[2183] Fix | Delete
// http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-8.3
[2184] Fix | Delete
if (!$this->_send_sftp_packet(NET_SFTP_REMOVE, pack('Na*', strlen($path), $path))) {
[2185] Fix | Delete
return false;
[2186] Fix | Delete
}
[2187] Fix | Delete
[2188] Fix | Delete
$response = $this->_get_sftp_packet();
[2189] Fix | Delete
if ($this->packet_type != NET_SFTP_STATUS) {
[2190] Fix | Delete
user_error('Expected SSH_FXP_STATUS');
[2191] Fix | Delete
[2192] Fix | Delete
return false;
[2193] Fix | Delete
}
[2194] Fix | Delete
[2195] Fix | Delete
// if $status isn't SSH_FX_OK it's probably SSH_FX_NO_SUCH_FILE or SSH_FX_PERMISSION_DENIED
[2196] Fix | Delete
extract(unpack('Nstatus', $this->_string_shift($response, 4)));
[2197] Fix | Delete
if ($status != NET_SFTP_STATUS_OK) {
[2198] Fix | Delete
$this->_logError($response, $status);
[2199] Fix | Delete
if (!$recursive) {
[2200] Fix | Delete
return false;
[2201] Fix | Delete
}
[2202] Fix | Delete
$i = 0;
[2203] Fix | Delete
$result = $this->_delete_recursive($path, $i);
[2204] Fix | Delete
$this->_read_put_responses($i);
[2205] Fix | Delete
[2206] Fix | Delete
return $result;
[2207] Fix | Delete
}
[2208] Fix | Delete
[2209] Fix | Delete
$this->_remove_from_stat_cache($path);
[2210] Fix | Delete
[2211] Fix | Delete
return true;
[2212] Fix | Delete
}
[2213] Fix | Delete
[2214] Fix | Delete
/**
[2215] Fix | Delete
* Recursively deletes directories on the SFTP server
[2216] Fix | Delete
*
[2217] Fix | Delete
* Minimizes directory lookups and SSH_FXP_STATUS requests for speed.
[2218] Fix | Delete
*
[2219] Fix | Delete
* @param String $path
[2220] Fix | Delete
* @param Integer $i
[2221] Fix | Delete
*
[2222] Fix | Delete
* @return Boolean
[2223] Fix | Delete
* @access private
[2224] Fix | Delete
*/
[2225] Fix | Delete
public function _delete_recursive($path, &$i)
[2226] Fix | Delete
{
[2227] Fix | Delete
if (!$this->_read_put_responses($i)) {
[2228] Fix | Delete
return false;
[2229] Fix | Delete
}
[2230] Fix | Delete
$i = 0;
[2231] Fix | Delete
$entries = $this->_list($path, true, false);
[2232] Fix | Delete
[2233] Fix | Delete
// normally $entries would have at least . and .. but it might not if the directories
[2234] Fix | Delete
// permissions didn't allow reading
[2235] Fix | Delete
if (empty($entries)) {
[2236] Fix | Delete
return false;
[2237] Fix | Delete
}
[2238] Fix | Delete
[2239] Fix | Delete
foreach ($entries as $filename => $props) {
[2240] Fix | Delete
if ($filename == '.' || $filename == '..') {
[2241] Fix | Delete
continue;
[2242] Fix | Delete
}
[2243] Fix | Delete
[2244] Fix | Delete
if (!isset($props['type'])) {
[2245] Fix | Delete
return false;
[2246] Fix | Delete
}
[2247] Fix | Delete
[2248] Fix | Delete
$temp = $path.'/'.$filename;
[2249] Fix | Delete
if ($props['type'] == NET_SFTP_TYPE_DIRECTORY) {
[2250] Fix | Delete
if (!$this->_delete_recursive($temp, $i)) {
[2251] Fix | Delete
return false;
[2252] Fix | Delete
}
[2253] Fix | Delete
} else {
[2254] Fix | Delete
if (!$this->_send_sftp_packet(NET_SFTP_REMOVE, pack('Na*', strlen($temp), $temp))) {
[2255] Fix | Delete
return false;
[2256] Fix | Delete
}
[2257] Fix | Delete
[2258] Fix | Delete
$i++;
[2259] Fix | Delete
[2260] Fix | Delete
if ($i >= NET_SFTP_QUEUE_SIZE) {
[2261] Fix | Delete
if (!$this->_read_put_responses($i)) {
[2262] Fix | Delete
return false;
[2263] Fix | Delete
}
[2264] Fix | Delete
$i = 0;
[2265] Fix | Delete
}
[2266] Fix | Delete
}
[2267] Fix | Delete
$this->_remove_from_stat_cache($path);
[2268] Fix | Delete
}
[2269] Fix | Delete
[2270] Fix | Delete
if (!$this->_send_sftp_packet(NET_SFTP_RMDIR, pack('Na*', strlen($path), $path))) {
[2271] Fix | Delete
return false;
[2272] Fix | Delete
}
[2273] Fix | Delete
[2274] Fix | Delete
$i++;
[2275] Fix | Delete
[2276] Fix | Delete
if ($i >= NET_SFTP_QUEUE_SIZE) {
[2277] Fix | Delete
if (!$this->_read_put_responses($i)) {
[2278] Fix | Delete
return false;
[2279] Fix | Delete
}
[2280] Fix | Delete
$i = 0;
[2281] Fix | Delete
}
[2282] Fix | Delete
[2283] Fix | Delete
return true;
[2284] Fix | Delete
}
[2285] Fix | Delete
[2286] Fix | Delete
/**
[2287] Fix | Delete
* Checks whether a file or directory exists
[2288] Fix | Delete
*
[2289] Fix | Delete
* @param String $path
[2290] Fix | Delete
*
[2291] Fix | Delete
* @return Boolean
[2292] Fix | Delete
* @access public
[2293] Fix | Delete
*/
[2294] Fix | Delete
public function file_exists($path)
[2295] Fix | Delete
{
[2296] Fix | Delete
if ($this->use_stat_cache) {
[2297] Fix | Delete
$path = $this->_realpath($path);
[2298] Fix | Delete
[2299] Fix | Delete
$result = $this->_query_stat_cache($path);
[2300] Fix | Delete
[2301] Fix | Delete
if (isset($result)) {
[2302] Fix | Delete
// return true if $result is an array or if it's int(1)
[2303] Fix | Delete
return $result !== false;
[2304] Fix | Delete
}
[2305] Fix | Delete
}
[2306] Fix | Delete
[2307] Fix | Delete
return $this->stat($path) !== false;
[2308] Fix | Delete
}
[2309] Fix | Delete
[2310] Fix | Delete
/**
[2311] Fix | Delete
* Tells whether the filename is a directory
[2312] Fix | Delete
*
[2313] Fix | Delete
* @param String $path
[2314] Fix | Delete
*
[2315] Fix | Delete
* @return Boolean
[2316] Fix | Delete
* @access public
[2317] Fix | Delete
*/
[2318] Fix | Delete
public function is_dir($path)
[2319] Fix | Delete
{
[2320] Fix | Delete
$result = $this->_get_stat_cache_prop($path, 'type');
[2321] Fix | Delete
if ($result === false) {
[2322] Fix | Delete
return false;
[2323] Fix | Delete
}
[2324] Fix | Delete
[2325] Fix | Delete
return $result === NET_SFTP_TYPE_DIRECTORY;
[2326] Fix | Delete
}
[2327] Fix | Delete
[2328] Fix | Delete
/**
[2329] Fix | Delete
* Tells whether the filename is a regular file
[2330] Fix | Delete
*
[2331] Fix | Delete
* @param String $path
[2332] Fix | Delete
*
[2333] Fix | Delete
* @return Boolean
[2334] Fix | Delete
* @access public
[2335] Fix | Delete
*/
[2336] Fix | Delete
public function is_file($path)
[2337] Fix | Delete
{
[2338] Fix | Delete
$result = $this->_get_stat_cache_prop($path, 'type');
[2339] Fix | Delete
if ($result === false) {
[2340] Fix | Delete
return false;
[2341] Fix | Delete
}
[2342] Fix | Delete
[2343] Fix | Delete
return $result === NET_SFTP_TYPE_REGULAR;
[2344] Fix | Delete
}
[2345] Fix | Delete
[2346] Fix | Delete
/**
[2347] Fix | Delete
* Tells whether the filename is a symbolic link
[2348] Fix | Delete
*
[2349] Fix | Delete
* @param String $path
[2350] Fix | Delete
*
[2351] Fix | Delete
* @return Boolean
[2352] Fix | Delete
* @access public
[2353] Fix | Delete
*/
[2354] Fix | Delete
public function is_link($path)
[2355] Fix | Delete
{
[2356] Fix | Delete
$result = $this->_get_stat_cache_prop($path, 'type');
[2357] Fix | Delete
if ($result === false) {
[2358] Fix | Delete
return false;
[2359] Fix | Delete
}
[2360] Fix | Delete
[2361] Fix | Delete
return $result === NET_SFTP_TYPE_SYMLINK;
[2362] Fix | Delete
}
[2363] Fix | Delete
[2364] Fix | Delete
/**
[2365] Fix | Delete
* Gets last access time of file
[2366] Fix | Delete
*
[2367] Fix | Delete
* @param String $path
[2368] Fix | Delete
*
[2369] Fix | Delete
* @return Mixed
[2370] Fix | Delete
* @access public
[2371] Fix | Delete
*/
[2372] Fix | Delete
public function fileatime($path)
[2373] Fix | Delete
{
[2374] Fix | Delete
return $this->_get_stat_cache_prop($path, 'atime');
[2375] Fix | Delete
}
[2376] Fix | Delete
[2377] Fix | Delete
/**
[2378] Fix | Delete
* Gets file modification time
[2379] Fix | Delete
*
[2380] Fix | Delete
* @param String $path
[2381] Fix | Delete
*
[2382] Fix | Delete
* @return Mixed
[2383] Fix | Delete
* @access public
[2384] Fix | Delete
*/
[2385] Fix | Delete
public function filemtime($path)
[2386] Fix | Delete
{
[2387] Fix | Delete
return $this->_get_stat_cache_prop($path, 'mtime');
[2388] Fix | Delete
}
[2389] Fix | Delete
[2390] Fix | Delete
/**
[2391] Fix | Delete
* Gets file permissions
[2392] Fix | Delete
*
[2393] Fix | Delete
* @param String $path
[2394] Fix | Delete
*
[2395] Fix | Delete
* @return Mixed
[2396] Fix | Delete
* @access public
[2397] Fix | Delete
*/
[2398] Fix | Delete
public function fileperms($path)
[2399] Fix | Delete
{
[2400] Fix | Delete
return $this->_get_stat_cache_prop($path, 'permissions');
[2401] Fix | Delete
}
[2402] Fix | Delete
[2403] Fix | Delete
/**
[2404] Fix | Delete
* Gets file owner
[2405] Fix | Delete
*
[2406] Fix | Delete
* @param String $path
[2407] Fix | Delete
*
[2408] Fix | Delete
* @return Mixed
[2409] Fix | Delete
* @access public
[2410] Fix | Delete
*/
[2411] Fix | Delete
public function fileowner($path)
[2412] Fix | Delete
{
[2413] Fix | Delete
return $this->_get_stat_cache_prop($path, 'uid');
[2414] Fix | Delete
}
[2415] Fix | Delete
[2416] Fix | Delete
/**
[2417] Fix | Delete
* Gets file group
[2418] Fix | Delete
*
[2419] Fix | Delete
* @param String $path
[2420] Fix | Delete
*
[2421] Fix | Delete
* @return Mixed
[2422] Fix | Delete
* @access public
[2423] Fix | Delete
*/
[2424] Fix | Delete
public function filegroup($path)
[2425] Fix | Delete
{
[2426] Fix | Delete
return $this->_get_stat_cache_prop($path, 'gid');
[2427] Fix | Delete
}
[2428] Fix | Delete
[2429] Fix | Delete
/**
[2430] Fix | Delete
* Gets file size
[2431] Fix | Delete
*
[2432] Fix | Delete
* @param String $path
[2433] Fix | Delete
*
[2434] Fix | Delete
* @return Mixed
[2435] Fix | Delete
* @access public
[2436] Fix | Delete
*/
[2437] Fix | Delete
public function filesize($path)
[2438] Fix | Delete
{
[2439] Fix | Delete
return $this->_get_stat_cache_prop($path, 'size');
[2440] Fix | Delete
}
[2441] Fix | Delete
[2442] Fix | Delete
/**
[2443] Fix | Delete
* Gets file type
[2444] Fix | Delete
*
[2445] Fix | Delete
* @param String $path
[2446] Fix | Delete
*
[2447] Fix | Delete
* @return Mixed
[2448] Fix | Delete
* @access public
[2449] Fix | Delete
*/
[2450] Fix | Delete
public function filetype($path)
[2451] Fix | Delete
{
[2452] Fix | Delete
$type = $this->_get_stat_cache_prop($path, 'type');
[2453] Fix | Delete
if ($type === false) {
[2454] Fix | Delete
return false;
[2455] Fix | Delete
}
[2456] Fix | Delete
[2457] Fix | Delete
switch ($type) {
[2458] Fix | Delete
case NET_SFTP_BLOCK_DEVICE:
[2459] Fix | Delete
return 'block';
[2460] Fix | Delete
case NET_SFTP_TYPE_CHAR_DEVICE:
[2461] Fix | Delete
return 'char';
[2462] Fix | Delete
case NET_SFTP_TYPE_DIRECTORY:
[2463] Fix | Delete
return 'dir';
[2464] Fix | Delete
case NET_SFTP_TYPE_FIFO:
[2465] Fix | Delete
return 'fifo';
[2466] Fix | Delete
case NET_SFTP_TYPE_REGULAR:
[2467] Fix | Delete
return 'file';
[2468] Fix | Delete
case NET_SFTP_TYPE_SYMLINK:
[2469] Fix | Delete
return 'link';
[2470] Fix | Delete
default:
[2471] Fix | Delete
return false;
[2472] Fix | Delete
}
[2473] Fix | Delete
}
[2474] Fix | Delete
[2475] Fix | Delete
/**
[2476] Fix | Delete
* Return a stat properity
[2477] Fix | Delete
*
[2478] Fix | Delete
* Uses cache if appropriate.
[2479] Fix | Delete
*
[2480] Fix | Delete
* @param String $path
[2481] Fix | Delete
* @param String $prop
[2482] Fix | Delete
*
[2483] Fix | Delete
* @return Mixed
[2484] Fix | Delete
* @access private
[2485] Fix | Delete
*/
[2486] Fix | Delete
public function _get_stat_cache_prop($path, $prop)
[2487] Fix | Delete
{
[2488] Fix | Delete
if ($this->use_stat_cache) {
[2489] Fix | Delete
$path = $this->_realpath($path);
[2490] Fix | Delete
[2491] Fix | Delete
$result = $this->_query_stat_cache($path);
[2492] Fix | Delete
[2493] Fix | Delete
if (is_object($result) && isset($result->$prop)) {
[2494] Fix | Delete
return $result->$prop;
[2495] Fix | Delete
}
[2496] Fix | Delete
}
[2497] Fix | Delete
[2498] Fix | Delete
$result = $this->stat($path);
[2499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function