Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/updraftp.../vendor/guzzleht.../guzzle/src/Cookie
File: FileCookieJar.php
<?php
[0] Fix | Delete
namespace GuzzleHttp\Cookie;
[1] Fix | Delete
[2] Fix | Delete
/**
[3] Fix | Delete
* Persists non-session cookies using a JSON formatted file
[4] Fix | Delete
*/
[5] Fix | Delete
class FileCookieJar extends CookieJar
[6] Fix | Delete
{
[7] Fix | Delete
/** @var string filename */
[8] Fix | Delete
private $filename;
[9] Fix | Delete
[10] Fix | Delete
/** @var bool Control whether to persist session cookies or not. */
[11] Fix | Delete
private $storeSessionCookies;
[12] Fix | Delete
[13] Fix | Delete
/**
[14] Fix | Delete
* Create a new FileCookieJar object
[15] Fix | Delete
*
[16] Fix | Delete
* @param string $cookieFile File to store the cookie data
[17] Fix | Delete
* @param bool $storeSessionCookies Set to true to store session cookies
[18] Fix | Delete
* in the cookie jar.
[19] Fix | Delete
*
[20] Fix | Delete
* @throws \RuntimeException if the file cannot be found or created
[21] Fix | Delete
*/
[22] Fix | Delete
public function __construct($cookieFile, $storeSessionCookies = false)
[23] Fix | Delete
{
[24] Fix | Delete
parent::__construct();
[25] Fix | Delete
$this->filename = $cookieFile;
[26] Fix | Delete
$this->storeSessionCookies = $storeSessionCookies;
[27] Fix | Delete
[28] Fix | Delete
if (file_exists($cookieFile)) {
[29] Fix | Delete
$this->load($cookieFile);
[30] Fix | Delete
}
[31] Fix | Delete
}
[32] Fix | Delete
[33] Fix | Delete
/**
[34] Fix | Delete
* Saves the file when shutting down
[35] Fix | Delete
*/
[36] Fix | Delete
public function __destruct()
[37] Fix | Delete
{
[38] Fix | Delete
$this->save($this->filename);
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
/**
[42] Fix | Delete
* Saves the cookies to a file.
[43] Fix | Delete
*
[44] Fix | Delete
* @param string $filename File to save
[45] Fix | Delete
* @throws \RuntimeException if the file cannot be found or created
[46] Fix | Delete
*/
[47] Fix | Delete
public function save($filename)
[48] Fix | Delete
{
[49] Fix | Delete
$json = [];
[50] Fix | Delete
foreach ($this as $cookie) {
[51] Fix | Delete
/** @var SetCookie $cookie */
[52] Fix | Delete
if (CookieJar::shouldPersist($cookie, $this->storeSessionCookies)) {
[53] Fix | Delete
$json[] = $cookie->toArray();
[54] Fix | Delete
}
[55] Fix | Delete
}
[56] Fix | Delete
[57] Fix | Delete
$jsonStr = \GuzzleHttp\json_encode($json);
[58] Fix | Delete
if (false === file_put_contents($filename, $jsonStr, LOCK_EX)) {
[59] Fix | Delete
throw new \RuntimeException("Unable to save file {$filename}");
[60] Fix | Delete
}
[61] Fix | Delete
}
[62] Fix | Delete
[63] Fix | Delete
/**
[64] Fix | Delete
* Load cookies from a JSON formatted file.
[65] Fix | Delete
*
[66] Fix | Delete
* Old cookies are kept unless overwritten by newly loaded ones.
[67] Fix | Delete
*
[68] Fix | Delete
* @param string $filename Cookie file to load.
[69] Fix | Delete
* @throws \RuntimeException if the file cannot be loaded.
[70] Fix | Delete
*/
[71] Fix | Delete
public function load($filename)
[72] Fix | Delete
{
[73] Fix | Delete
$json = file_get_contents($filename);
[74] Fix | Delete
if (false === $json) {
[75] Fix | Delete
throw new \RuntimeException("Unable to load file {$filename}");
[76] Fix | Delete
} elseif ($json === '') {
[77] Fix | Delete
return;
[78] Fix | Delete
}
[79] Fix | Delete
[80] Fix | Delete
$data = \GuzzleHttp\json_decode($json, true);
[81] Fix | Delete
if (is_array($data)) {
[82] Fix | Delete
foreach (json_decode($json, true) as $cookie) {
[83] Fix | Delete
$this->setCookie(new SetCookie($cookie));
[84] Fix | Delete
}
[85] Fix | Delete
} elseif (strlen($data)) {
[86] Fix | Delete
throw new \RuntimeException("Invalid cookie file: {$filename}");
[87] Fix | Delete
}
[88] Fix | Delete
}
[89] Fix | Delete
}
[90] Fix | Delete
[91] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function