function saveRackCode() { assertStringArg('rackcode'); // For the test to succeed, unescape LFs, strip CRs. $newcode = dos2unix($_REQUEST['rackcode']); $parseTree = getRackCode($newcode); if ($parseTree['result'] != 'ACK') { showFuncMessage(__FUNCTION__, 'ERR1', array($parseTree['load'])); return; } saveScript('RackCode', $newcode); saveScript('RackCodeCache', base64_encode(serialize($parseTree))); showFuncMessage(__FUNCTION__, 'OK'); }
function verifyCodeAJAX() { global $pageno, $tabno; $pageno = 'perms'; $tabno = 'edit'; fixContext(); assertPermission(); genericAssertion('code', 'string'); $result = getRackCode(dos2unix($_REQUEST['code'])); if ($result['result'] == 'ACK') { echo "ACK\n"; } else { echo "NAK\n" . $result['load']; } }
if (getConfigVar('DB_VERSION') != CODE_VERSION) { echo '<p align=justify>This Racktables installation seems to be ' . 'just upgraded to version ' . CODE_VERSION . ', while the ' . 'database version is ' . getConfigVar('DB_VERSION') . '.<br>No user will be ' . 'either authenticated or shown any page until the upgrade is ' . "finished.<br>Follow <a href='?module=upgrade'>this link</a> and " . 'authenticate as administrator to finish the upgrade.</p>'; exit(1); } if (!mb_internal_encoding('UTF-8')) { throw new RackTablesError('Failed setting multibyte string encoding to UTF-8', RackTablesError::INTERNAL); } $rackCodeCache = loadScript('RackCodeCache'); if ($rackCodeCache == NULL or !strlen($rackCodeCache)) { $rackCode = getRackCode(loadScript('RackCode')); saveScript('RackCodeCache', base64_encode(serialize($rackCode))); } else { $rackCode = unserialize(base64_decode($rackCodeCache)); if ($rackCode === FALSE) { saveScript('RackCodeCache', ''); $rackCode = getRackCode(loadScript('RackCode')); } } // avoid notices being thrown date_default_timezone_set(getConfigVar('DATETIME_ZONE')); // Depending on the 'result' value the 'load' carries either the // parse tree or error message. The latter case is a bug, because // RackCode saving function was supposed to validate its input. if ($rackCode['result'] != 'ACK') { throw new RackTablesError($rackCode['load'], RackTablesError::INTERNAL); } $rackCode = $rackCode['load']; // Only call buildPredicateTable() once and save the result, because it will remain // constant during one execution for constraints processing. $pTable = buildPredicateTable($rackCode); // Constraints parse trees aren't cached in the database, so the least to keep