Monday, November 08, 2010 at 12:06 AM.

system.verbs.builtins.userland.trialVersionCheck

on trialVersionCheck (flOpenSerialNumberPage=true) {
	<<Changes
		<<9/10/02; 4:56:35 PM by JES
			<<New optional parameter, flOpenSerialNumberPage. If true, open the serial number page when the trial expires. If false, just disable the UI. Defaults to true. Return true if the trial version has expired, or false if the trial is not expired or not a trial version.
		<<7/31/02; 4:59:53 PM by JES
			<<Open the serial number page in the admin site, not inthe control panel.
		<<4/8/02; 3:30:31 PM by JES
			<<Cribbed from radio.thread.agents.trialVersion
	local (daysInTrial = 60);
	bundle { //initialize userland.trialVersion for Frontier
		if not defined (userland.trialVersion) {
			new (tableType, @userland.trialVersion)};
		if not defined (userland.trialVersion.flTrialVersion) {
			local (flTrialVersion = true);
			if (user.prefs.serialNumber != "") and (user.prefs.serialNumber != "A1NX-5JF5-1909") {
				flTrialVersion = userland.isValidSerialNumber (string.upper (user.prefs.serialNumber))};
			userland.trialVersion.flTrialVersion = flTrialVersion};
		if not defined (userland.trialVersion.whenInstalled) {
			userland.trialVersion.whenInstalled = clock.now ()};
		if not defined (userland.trialVersion.flExpired) {
			userland.trialVersion.flExpired = false}};
	if userland.trialVersion.flTrialVersion { //check to see if we already have a valid serial number
		<<The server admin may have entered a serial number directly into user.prefs.serialNumber.
		if userland.isValidSerialNumber (string.upper (user.prefs.serialNumber)) and (user.prefs.serialNumber != "A1NX-5JF5-1909") {
			userland.trialVersion.flTrialVersion = false}};
	if not userland.trialVersion.flTrialVersion { //if not trial version, make sure whenRegistered is defined
		if not defined (userland.trialVersion.whenRegistered) {
			userland.trialVersion.whenRegistered = clock.now ()}};
	if userland.trialVersion.flTrialVersion { //trial version -- check for expiration
		if (clock.now () - userland.trialVersion.whenInstalled) > (daysInTrial * 24 * 60 * 60) {
			if not userland.trialVersion.flExpired {
				if flOpenSerialNumberPage {
					if system.environment.isRadio {
						radio.menuCommands.openPage (radio.data.systemUrls.serialNumber)}
					else { //Frontier
						local (server = "127.0.0.1");
						if user.inetd.config.http2.port != 80 {
							server = server + ":" + user.inetd.config.http2.port};
						if not defined (mainResponder) {
							dialog.alert ("This trial version of Frontier has expired.");
							return (true)}
						else {
							webbrowser.openUrl ("http://" + server + mainResponder.adminSite.urls.serialNumber);
							webbrowser.bringtofront ()}}};
				system.temp.Frontier.flWasExpired = true;
				userland.trialVersion.flExpired = true}}};
	if userland.trialVersion.flExpired { //disable UI elements if flExpired is true
		system.temp.Frontier.flWasExpired = true;
		on closeIt (adr) {
			if defined (adr^) {
				if table.getRootAddress (adr) == adr { //hide the window
					window.hide (adr);
					return (true)}};
			try {
				window.close (adr)}};
		window.visit (@closeIt);
		if defined (Frontier.hideApplication) {
			Frontier.hideApplication ()};
		menu.clearMenuBar ()}
	else { //restore UI elements if flExpired is false
		local (flRestoreUi = false);
		if not userland.trialVersion.flTrialVersion {
			if defined (system.temp.Frontier.flWasExpired) {
				if system.temp.Frontier.flWasExpired {
					flRestoreUi = true}};
			if not menu.isInstalled (@Frontier.tools.menu) {
				flRestoreUi = true}};
		if flRestoreUi {
			menu.noSuite ();
			if user.prefs.openAboutWindow {
				window.about ()};
			system.temp.Frontier.flWasExpired = false}};
	return (userland.trialVersion.flExpired and userland.trialVersion.flTrialVersion)}



This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.