本文整理汇总了PHP中http_class::SaveCookies方法的典型用法代码示例。如果您正苦于以下问题:PHP http_class::SaveCookies方法的具体用法?PHP http_class::SaveCookies怎么用?PHP http_class::SaveCookies使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类http_class
的用法示例。
在下文中一共展示了http_class::SaveCookies方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: flush
echo "<H2><LI>Getting the response body ...</LI</H2>\n";
for (;;) {
$error = $http->ReadReplyBody($body, 1000);
if ($error != "" || strlen($body) == 0) {
break;
}
}
flush();
}
}
$http->Close();
}
if (strlen($error) == 0) {
echo "<H2><LI>Test saving and restoring cookies...</LI</H2>\n";
flush();
$http->SaveCookies($site_cookies);
if (strlen($error = $http->RestoreCookies($site_cookies, 1)) == 0) {
$http->SaveCookies($saved_cookies);
if (strcmp(serialize($saved_cookies), serialize($site_cookies))) {
echo "<H2>FAILED: the saved cookies do not match the restored cookies.</H2>\n";
} else {
echo "<H2>OK: the saved cookies match the restored cookies.</H2>\n";
}
}
}
if (strlen($error)) {
echo "<CENTER><H2>Error: ", $error, "</H2><CENTER>\n";
}
?>
</UL>
<HR>
示例2: UpdateStep2
function UpdateStep2()
{
global $clang, $scriptname, $homedir, $buildnumber, $updatebuild, $debug, $rootdir;
// Request the list with changed files from the server
require_once($homedir."/classes/http/http.php");
$updatekey=getGlobalSetting('updatekey');
echo '<div class="header ui-widget-header">'.sprintf($clang->gT('ComfortUpdate step %s'),'2').'</div><div class="updater-background"><br />';
$http=new http_class;
/* Connection timeout */
$http->timeout=0;
/* Data transfer timeout */
$http->data_timeout=0;
$http->user_agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
$http->GetRequestArguments("http://update.limesurvey.org/updates/update/$buildnumber/$updatebuild/$updatekey",$arguments);
$updateinfo=false;
$error=$http->Open($arguments);
$error=$http->SendRequest($arguments);
if($error=="") {
$body=''; $full_body='';
for(;;){
$error = $http->ReadReplyBody($body,10000);
if($error != "" || strlen($body)==0) break;
$full_body .= $body;
}
$updateinfo=json_decode($full_body,true);
$http->SaveCookies($site_cookies);
}
else
{
print( $error );
}
if (isset($updateinfo['error']))
{
echo $clang->gT('On requesting the update information from limesurvey.org there has been an error:').'<br />';
if ($updateinfo['error']==1)
{
setGlobalSetting('updatekey','');
echo $clang->gT('Your update key is invalid and was removed. ').'<br />';
}
else
echo $clang->gT('On requesting the update information from limesurvey.org there has been an error:').'<br />';
}
// okay, updateinfo now contains all necessary updateinformation
// Now check if the existing files have the mentioned checksum
$existingfiles=array();
$modifiedfiles=array();
$readonlyfiles=array();
if (!isset($updateinfo['files']))
{
echo "<div class='messagebox ui-corner-all'>
<div class='warningheader'>".$clang->gT('Update server busy')."</div>
<p>".$clang->gT('The update server is currently busy. This usually happens when the update files for a new version are being prepared.')."<br /><br />
".$clang->gT('Please be patient and try again in about 10 minutes.')."</p></div>
<p><button onclick=\"window.open('$scriptname?action=globalsettings', '_top')\">".sprintf($clang->gT('Back to global settings'),'4')."</button></p>";
}
else
{
foreach ($updateinfo['files'] as $afile)
{
if ($afile['type']=='A' && !file_exists($rootdir.$afile['file']))
{
$searchpath=$rootdir.$afile['file'];
$is_writable=is_writable(dirname($searchpath));
while (!$is_writable && strlen($searchpath)>strlen($rootdir))
{
$searchpath=dirname($searchpath);
if (file_exists($searchpath))
{
$is_writable=is_writable($searchpath);
break;
}
}
if (!$is_writable)
{
$readonlyfiles[]=$searchpath;
}
}
elseif (file_exists($rootdir.$afile['file']) && !is_writable($rootdir.$afile['file'])) {
$readonlyfiles[]=$rootdir.$afile['file'];
}
if ($afile['type']=='A' && file_exists($rootdir.$afile['file']))
{
//A new file, check if this already exists
$existingfiles[]=$afile;
}
elseif (($afile['type']=='D' || $afile['type']=='M') && is_file($rootdir.$afile['file']) && sha1_file($rootdir.$afile['file'])!=$afile['checksum']) // A deleted or modified file - check if it is unmodified
{
//.........这里部分代码省略.........
示例3: _readChangelog
private function _readChangelog(http_class $http)
{
$szLines = '';
$szResponse = '';
for (;;) {
$httperror = $http->ReadReplyBody($szLines, 10000);
if ($httperror != "" || strlen($szLines) == 0) {
$changelog = json_decode($szResponse, true);
$http->SaveCookies($cookies);
return array($httperror, $changelog, $cookies);
}
$szResponse .= $szLines;
}
}