Exemple #1
0
            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>
Exemple #2
0
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
            {
                $modifiedfiles[]=$afile;
            }
        }

        echo '<h3>'.$clang->gT('Checking existing LimeSurvey files...').'</h3>';
        if (count($readonlyfiles)>0)
        {
            echo '<span class="warningtitle">'.$clang->gT('Warning: The following files/directories need to be updated but their permissions are set to read-only.').'<br />';
            echo $clang->gT('You must set according write permissions on these filese before you can proceed. If you are unsure what to do please contact your system administrator for advice.').'<br />';
            echo '</span><ul>';
            $readonlyfiles=array_unique($readonlyfiles);
            sort($readonlyfiles);
            foreach ($readonlyfiles as $readonlyfile)
            {
                echo '<li>'.htmlspecialchars($readonlyfile).'</li>';
            }
            echo '</ul>';
        }
        if (count($existingfiles)>0)
        {
            echo $clang->gT('The following files would be added by the update but already exist. This is very unusual and may be co-incidental.').'<br />';
            echo $clang->gT('We recommend that these files should be replaced by the update procedure.').'<br />';
            echo '<ul>';
            sort($existingfiles);
            foreach ($existingfiles as $existingfile)
            {
                echo '<li>'.htmlspecialchars($existingfile['file']).'</li>';
            }
            echo '</ul>';
        }

        if (count($modifiedfiles)>0)
        {
            echo $clang->gT('The following files will be modified or deleted but were already modified by someone else.').'<br />';
            echo $clang->gT('We recommend that these files should be replaced by the update procedure.').'<br />';
            echo '<ul>';
            sort($modifiedfiles);
            foreach ($modifiedfiles as $modifiedfile)
            {
                echo '<li>'.htmlspecialchars($modifiedfile['file']).'</li>';
            }
            echo '</ul>';
        }

        if (count($readonlyfiles)>0)
        {
            echo '<br />'.$clang->gT('When checking your file permissions we found one or more problems. Please check for any error messages above and fix these before you can proceed.');
            echo "<p><button onclick=\"window.open('$scriptname?action=update&amp;subaction=step2', '_top')\"";
            echo ">".$clang->gT('Check again')."</button></p>";
        }
        else
        {
            echo $clang->gT('Please check any problems above and then proceed to the next step.').'<br />';
            echo "<p><button onclick=\"window.open('$scriptname?action=update&amp;subaction=step3', '_top')\" ";
            echo ">".sprintf($clang->gT('Proceed to step %s'),'3')."</button></p>";

        }
    }
    $_SESSION['updateinfo']=$updateinfo;
    $_SESSION['updatesession']=$site_cookies;
}
Exemple #3
0
 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;
     }
 }