Source Code Protection

T

Tom Pepper Willett

How do I stop people from downloading my graphics or code?

http://www.jamesshuggins.com/h/web1/how_do_i_stop_downloading.htm

http://www.jimcoaddins.com/protect.htm


--
===
Tom "Pepper" Willett
Microsoft MVP - FrontPage
---
About FrontPage 2003:
http://office.microsoft.com/home/office.aspx?assetid=FX01085802
FrontPage 2003 Product Information:
http://www.microsoft.com/office/frontpage/prodinfo/default.mspx
Understanding FrontPage:
http://msdn.microsoft.com/office/understanding/frontpage/
FrontPage 2002 Server Extensions Support Center:
http://support.microsoft.com/default.aspx?scid=fh;en-us;fp10se
===
| How do I protect my source codes? ASP as well as HTML?
|
|
 
K

Kevin Spencer

ASP code is on the server, and is not viewable by users browsing your web.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
M

MD Websunlimited

ASP scripting is automatically protected.

It is possible to protect HTML but very very time consuming.
 
M

Murray

It is possible to protect HTML but very very time consuming.

The only way I know of is to require the visitor to download and install a
browser plugin, or to use a hardware dongle. In other words, there is no
practical way to do it, at least not in our use space.
 
M

MD Websunlimited

I disagree you can protect your source from the average consumer that does not require a browser plugin or dongle.

On the following page the implementation script for Form Calculator is protected. The same can be done to protect the HTML of the web page.

http://www.websunlimited.com/order/Product/FormCalc/formcalc.htm

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible
 
M

Murray

You mean by this?

<script id="WU_Expression" type="text/javascript" src="formcalc.asp" >

containing this -

var token = ''; // holds the token found var prog = ''; var progIndex = 0;
var oForm; var places = 2; var prepend = 0; var DELIMITER = 1; var VARIABLE
= 2; var NUMBER = 3; var TOKEN_SIZE = 32; var TRUE = -1; var FALSE = 0;
function Expression(theForm,theExpression,Places,Prepend) { places = Places;
prepend = Prepend; progIndex = 0; prog = theExpression; oForm = theForm;
get_token(); if(!token) { serror(2); } Level1(); } ?

I see no protection there, or am I misunderstanding something?

But the original question was -

and the answer is a) you don't need to protect ASP, and b) you cannot (as a
practical matter) protect your HTML. You can make it annoying, but you
cannot protect it without using the devices I mentioned earlier - at least I
don't know of any way to do so.

--
Murray

I disagree you can protect your source from the average consumer that does
not require a browser plugin or dongle.

On the following page the implementation script for Form Calculator is
protected. The same can be done to protect the HTML of the web page.

http://www.websunlimited.com/order/Product/FormCalc/formcalc.htm

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible
 
K

Kevin Spencer

Hi Mike,

Is this the protected script?

[formcalc.asp]

var token = ''; // holds the token found
var prog = '';
var progIndex = 0;
var oForm;
var places = 2;
var prepend = 0;
var DELIMITER = 1;
var VARIABLE = 2;
var NUMBER = 3;
var TOKEN_SIZE = 32;
var TRUE = -1;
var FALSE = 0;

function Expression(theForm,theExpression,Places,Prepend) {
places = Places;
prepend = Prepend;
progIndex = 0;
prog = theExpression;
oForm = theForm;
get_token();
if(!token) {
serror(2);
}

Level1();
}

// process an assignment statement
function Level1()
{

var slot;
var ttok_type;
var temp_token;
var result = 0.0;


if(tok_type == VARIABLE) {
// save old token
temp_token = token;
ttok_type = tok_type;
if(typeof oForm[token] != "undefined" ) {
slot = oForm[token];
} else {
serror(3);
}
get_token();
if(token != '=') {
putback();
token = temp_token;
tok_type = ttok_type;
} else {
get_token();
result = Level2();
slot.value = round(result,places);
return;
}
}
result = Level2();
return result;
}

function Level2()
{
var op = '';
var hold = 0;
var result = 0;

result = Level3();
while((op = token) == '+' || op == '-') {
get_token();
hold = Level3();
result = arith(op,result, hold);
}
return result;
}

// multiply or divide two terms
function Level3()
{
var op = '';
var hold = 0;
var result = 0.0;
result = Level4();
while((op = token) == '*' || op == '/') {
get_token();
hold = Level4();
result = arith(op,result, hold);
}
return result;
}

// process integer expoent
function Level4()
{
var hold = 0;
var result = 0;

result = Level5();
if((token) == '^') {
get_token();
hold = Level4();
result = arith('^',result, hold);
}
return result;
}

// unary + or -
function Level5()
{
var op = '';
var result = 0.0;

op = 0;

if((tok_type==DELIMITER) && token == '+' || token == '-') {
op = token;
get_token();
}
result = Level6();
if(op)
result = unary(op,result);
return result;
}

// process parenthesized expression
function Level6()
{
var result = 0.0;

if((token == '(') && (tok_type == DELIMITER)) {
get_token();
result = Level1();
if(token != ')')
serror(1);
get_token();
} else
result = primitive();
return result

}

function primitive()
{
var slot = 0;
var result = 0.0;
var sValue = '';
var i = 0;
switch(tok_type) {
case VARIABLE :
if(typeof oForm[token] == "undefined")
result = 0.0;
else {
switch (oForm[token].tagName) {
case 'INPUT' :
sValue = oForm[token].value;
while(sValue.charAt(i) == ' ') ++i;
if(sValue.charAt(i) == '$') ++i;
sValue = sValue.substr(i,sValue.length-i);
if (!isNumber(sValue)) serror(4);
result = parseFloat(sValue);
if (isNaN(result)) result = 0;
break;
case 'SELECT' :
sValue = oForm[token].options[oForm[token].selectedIndex].value;
while(sValue.charAt(i) == ' ') ++i;
if(sValue.charAt(i) == '$') ++i;
sValue = sValue.substr(i,sValue.length-i);
if (!isNumber(sValue)) serror(0);
result = parseFloat(sValue);
if (isNaN(result)) result = 0;
break;
default:
if( oForm[token].length > 0 ) {
for(i=0; i < oForm[token].length; i++) {
if(oForm[token].checked) {
sValue = oForm[token].value;
while(sValue.charAt(i) == ' ') ++i;
if(sValue.charAt(i) == '$') ++i;
sValue = sValue.substr(i,sValue.length-i);
if (!isNumber(sValue)) serror(4);
isNaN(parseFloat(sValue)) ? result += 0 : result +=
parseFloat(sValue);
var sType = oForm[token].type.toLowerCase();
sType = sType.toLowerCase();
if (sType == 'radio') break;
}
}
}
break;
}
}
get_token();
return result;
case NUMBER:
result = parseFloat(token);
get_token();
return result;
default:
return result;
}
}

// do the math functions
function arith(o,r,h)
{
var t = 0.0;
var ex = 0.0;
switch(o) {
case '-':
r = r - h;
break;
case '+':
r = r + h;
break;
case '*':
r = r * h;
break;
case '/':
r = r / h;
break;
case '%':
t = ((r) / (h));
r = r - (t*(h));
break;
case '^':
ex = r;
if(h==0) {
r = 1.0;
break;
}
for(t=h-1; t>0; --t) r = (r) * ex; // brute force
break;
}
return r;
}

function unary(o, r)
{
if(o=='-') r = -(r);
return r;
}

// return a token to its resting place
function putback()
{
var t = '';

t = token;
for(;t;t++) progIndex--;
}

// find the value of a variable
function find_var(s)
{
var temp = '';

temp = oForm.s.value // if not defined then zero
if( temp == '' ) {
return(0.0);
}
return parseFloat(temp);
}

function serror(error)
{

var e = new Array;

e[0] = "Syntax error";
e[1] = "Unbalanced parentheses";
e[2] = "no expression present";
e[3] = "Form field does not exist " + token;
e[4] = "Not a number"

alert(e[error] + ' - ' + token);

}

function get_token()
{
var temp = '';
tok_type = 0;

while(prog.charAt(progIndex) == ' ') ++progIndex; // skip spaces
if(is_in(prog.charAt(progIndex), "+-*/%^=()")) {
tok_type = DELIMITER;
temp += prog.charAt(progIndex++);
} else if(isAlpha(prog.charAt(progIndex)) || prog.charAt(progIndex) == '$')
{
while(!isdelim(prog.charAt(progIndex))) temp += prog.charAt(progIndex++);
tok_type = VARIABLE;
} else if (isDigit(prog.charAt(progIndex)) || prog.charAt(progIndex) ==
'.') {
while(!isdelim(prog.charAt(progIndex)))
temp += prog.charAt(progIndex++);
tok_type = NUMBER;
}
//--temp;
//while(isspace(temp)) --temp ;
token = temp;

}

// test for delimiter
function isdelim(c)
{
if(is_in(c, "+-/*%^=() ") || c=='\t' || c=='\r')
return 1;
return 0;
}

//test for alpha
function isAlpha(c) {
var sAlpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
if (is_in(c,sAlpha)) return 1; else return 0;
}

function isDigit(c) {
var Digits = '0123456789';
if (is_in(c,Digits)) return 1; else return 0;
}

function isNumber(s) {
var dec = 0;
var i = 0;
if(s.charAt(i) == '-' || s.charAt(i) == '+') ++i;
for(i; i<s.length; i++) {
if(!isDigit(s.charAt(i))) {
if (s.charAt(i) != '.' || dec )
return 0;
else
++dec;
}
}
return 1;
}

function is_in(ch,s)
{
if(s.indexOf(ch) > -1) return 1; else return 0;
}

function round(number,places) {
number = Math.round(number*Math.pow(10,places))/Math.pow(10,places);
number += '';
var x = number.lastIndexOf('.');
if (x == -1 && places > 0) { number += '.'; x = number.length -1; }
for ( i = ((number.length-1) - x); i < places; i++) number += '0';
return prepend ? '$' + number : number;
}


--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

I disagree you can protect your source from the average consumer that does
not require a browser plugin or dongle.

On the following page the implementation script for Form Calculator is
protected. The same can be done to protect the HTML of the web page.

http://www.websunlimited.com/order/Product/FormCalc/formcalc.htm

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible
 
M

MD Websunlimited

Kevin, Murry,

Oops, I was in a hurry to set it up. Let me see what I did wrong.

Like I said it can be time consuming.

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible

Kevin Spencer said:
Hi Mike,

Is this the protected script?

[formcalc.asp]

var token = ''; // holds the token found
var prog = '';
var progIndex = 0;
var oForm;
var places = 2;
var prepend = 0;
var DELIMITER = 1;
var VARIABLE = 2;
var NUMBER = 3;
var TOKEN_SIZE = 32;
var TRUE = -1;
var FALSE = 0;

function Expression(theForm,theExpression,Places,Prepend) {
places = Places;
prepend = Prepend;
progIndex = 0;
prog = theExpression;
oForm = theForm;
get_token();
if(!token) {
serror(2);
}

Level1();
}

// process an assignment statement
function Level1()
{

var slot;
var ttok_type;
var temp_token;
var result = 0.0;


if(tok_type == VARIABLE) {
// save old token
temp_token = token;
ttok_type = tok_type;
if(typeof oForm[token] != "undefined" ) {
slot = oForm[token];
} else {
serror(3);
}
get_token();
if(token != '=') {
putback();
token = temp_token;
tok_type = ttok_type;
} else {
get_token();
result = Level2();
slot.value = round(result,places);
return;
}
}
result = Level2();
return result;
}

function Level2()
{
var op = '';
var hold = 0;
var result = 0;

result = Level3();
while((op = token) == '+' || op == '-') {
get_token();
hold = Level3();
result = arith(op,result, hold);
}
return result;
}

// multiply or divide two terms
function Level3()
{
var op = '';
var hold = 0;
var result = 0.0;
result = Level4();
while((op = token) == '*' || op == '/') {
get_token();
hold = Level4();
result = arith(op,result, hold);
}
return result;
}

// process integer expoent
function Level4()
{
var hold = 0;
var result = 0;

result = Level5();
if((token) == '^') {
get_token();
hold = Level4();
result = arith('^',result, hold);
}
return result;
}

// unary + or -
function Level5()
{
var op = '';
var result = 0.0;

op = 0;

if((tok_type==DELIMITER) && token == '+' || token == '-') {
op = token;
get_token();
}
result = Level6();
if(op)
result = unary(op,result);
return result;
}

// process parenthesized expression
function Level6()
{
var result = 0.0;

if((token == '(') && (tok_type == DELIMITER)) {
get_token();
result = Level1();
if(token != ')')
serror(1);
get_token();
} else
result = primitive();
return result

}

function primitive()
{
var slot = 0;
var result = 0.0;
var sValue = '';
var i = 0;
switch(tok_type) {
case VARIABLE :
if(typeof oForm[token] == "undefined")
result = 0.0;
else {
switch (oForm[token].tagName) {
case 'INPUT' :
sValue = oForm[token].value;
while(sValue.charAt(i) == ' ') ++i;
if(sValue.charAt(i) == '$') ++i;
sValue = sValue.substr(i,sValue.length-i);
if (!isNumber(sValue)) serror(4);
result = parseFloat(sValue);
if (isNaN(result)) result = 0;
break;
case 'SELECT' :
sValue = oForm[token].options[oForm[token].selectedIndex].value;
while(sValue.charAt(i) == ' ') ++i;
if(sValue.charAt(i) == '$') ++i;
sValue = sValue.substr(i,sValue.length-i);
if (!isNumber(sValue)) serror(0);
result = parseFloat(sValue);
if (isNaN(result)) result = 0;
break;
default:
if( oForm[token].length > 0 ) {
for(i=0; i < oForm[token].length; i++) {
if(oForm[token].checked) {
sValue = oForm[token].value;
while(sValue.charAt(i) == ' ') ++i;
if(sValue.charAt(i) == '$') ++i;
sValue = sValue.substr(i,sValue.length-i);
if (!isNumber(sValue)) serror(4);
isNaN(parseFloat(sValue)) ? result += 0 : result +=
parseFloat(sValue);
var sType = oForm[token].type.toLowerCase();
sType = sType.toLowerCase();
if (sType == 'radio') break;
}
}
}
break;
}
}
get_token();
return result;
case NUMBER:
result = parseFloat(token);
get_token();
return result;
default:
return result;
}
}

// do the math functions
function arith(o,r,h)
{
var t = 0.0;
var ex = 0.0;
switch(o) {
case '-':
r = r - h;
break;
case '+':
r = r + h;
break;
case '*':
r = r * h;
break;
case '/':
r = r / h;
break;
case '%':
t = ((r) / (h));
r = r - (t*(h));
break;
case '^':
ex = r;
if(h==0) {
r = 1.0;
break;
}
for(t=h-1; t>0; --t) r = (r) * ex; // brute force
break;
}
return r;
}

function unary(o, r)
{
if(o=='-') r = -(r);
return r;
}

// return a token to its resting place
function putback()
{
var t = '';

t = token;
for(;t;t++) progIndex--;
}

// find the value of a variable
function find_var(s)
{
var temp = '';

temp = oForm.s.value // if not defined then zero
if( temp == '' ) {
return(0.0);
}
return parseFloat(temp);
}

function serror(error)
{

var e = new Array;

e[0] = "Syntax error";
e[1] = "Unbalanced parentheses";
e[2] = "no expression present";
e[3] = "Form field does not exist " + token;
e[4] = "Not a number"

alert(e[error] + ' - ' + token);

}

function get_token()
{
var temp = '';
tok_type = 0;

while(prog.charAt(progIndex) == ' ') ++progIndex; // skip spaces
if(is_in(prog.charAt(progIndex), "+-*/%^=()")) {
tok_type = DELIMITER;
temp += prog.charAt(progIndex++);
} else if(isAlpha(prog.charAt(progIndex)) || prog.charAt(progIndex) == '$')
{
while(!isdelim(prog.charAt(progIndex))) temp += prog.charAt(progIndex++);
tok_type = VARIABLE;
} else if (isDigit(prog.charAt(progIndex)) || prog.charAt(progIndex) ==
'.') {
while(!isdelim(prog.charAt(progIndex)))
temp += prog.charAt(progIndex++);
tok_type = NUMBER;
}
//--temp;
//while(isspace(temp)) --temp ;
token = temp;

}

// test for delimiter
function isdelim(c)
{
if(is_in(c, "+-/*%^=() ") || c=='\t' || c=='\r')
return 1;
return 0;
}

//test for alpha
function isAlpha(c) {
var sAlpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
if (is_in(c,sAlpha)) return 1; else return 0;
}

function isDigit(c) {
var Digits = '0123456789';
if (is_in(c,Digits)) return 1; else return 0;
}

function isNumber(s) {
var dec = 0;
var i = 0;
if(s.charAt(i) == '-' || s.charAt(i) == '+') ++i;
for(i; i<s.length; i++) {
if(!isDigit(s.charAt(i))) {
if (s.charAt(i) != '.' || dec )
return 0;
else
++dec;
}
}
return 1;
}

function is_in(ch,s)
{
if(s.indexOf(ch) > -1) return 1; else return 0;
}

function round(number,places) {
number = Math.round(number*Math.pow(10,places))/Math.pow(10,places);
number += '';
var x = number.lastIndexOf('.');
if (x == -1 && places > 0) { number += '.'; x = number.length -1; }
for ( i = ((number.length-1) - x); i < places; i++) number += '0';
return prepend ? '$' + number : number;
}


--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

I disagree you can protect your source from the average consumer that does
not require a browser plugin or dongle.

On the following page the implementation script for Form Calculator is
protected. The same can be done to protect the HTML of the web page.

http://www.websunlimited.com/order/Product/FormCalc/formcalc.htm

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible
 
K

Kevin Spencer

Challenge me, Mike! ;-)

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

MD Websunlimited said:
Kevin, Murry,

Oops, I was in a hurry to set it up. Let me see what I did wrong.

Like I said it can be time consuming.

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible

Hi Mike,

Is this the protected script?

[formcalc.asp]

var token = ''; // holds the token found
var prog = '';
var progIndex = 0;
var oForm;
var places = 2;
var prepend = 0;
var DELIMITER = 1;
var VARIABLE = 2;
var NUMBER = 3;
var TOKEN_SIZE = 32;
var TRUE = -1;
var FALSE = 0;

function Expression(theForm,theExpression,Places,Prepend) {
places = Places;
prepend = Prepend;
progIndex = 0;
prog = theExpression;
oForm = theForm;
get_token();
if(!token) {
serror(2);
}

Level1();
}

// process an assignment statement
function Level1()
{

var slot;
var ttok_type;
var temp_token;
var result = 0.0;


if(tok_type == VARIABLE) {
// save old token
temp_token = token;
ttok_type = tok_type;
if(typeof oForm[token] != "undefined" ) {
slot = oForm[token];
} else {
serror(3);
}
get_token();
if(token != '=') {
putback();
token = temp_token;
tok_type = ttok_type;
} else {
get_token();
result = Level2();
slot.value = round(result,places);
return;
}
}
result = Level2();
return result;
}

function Level2()
{
var op = '';
var hold = 0;
var result = 0;

result = Level3();
while((op = token) == '+' || op == '-') {
get_token();
hold = Level3();
result = arith(op,result, hold);
}
return result;
}

// multiply or divide two terms
function Level3()
{
var op = '';
var hold = 0;
var result = 0.0;
result = Level4();
while((op = token) == '*' || op == '/') {
get_token();
hold = Level4();
result = arith(op,result, hold);
}
return result;
}

// process integer expoent
function Level4()
{
var hold = 0;
var result = 0;

result = Level5();
if((token) == '^') {
get_token();
hold = Level4();
result = arith('^',result, hold);
}
return result;
}

// unary + or -
function Level5()
{
var op = '';
var result = 0.0;

op = 0;

if((tok_type==DELIMITER) && token == '+' || token == '-') {
op = token;
get_token();
}
result = Level6();
if(op)
result = unary(op,result);
return result;
}

// process parenthesized expression
function Level6()
{
var result = 0.0;

if((token == '(') && (tok_type == DELIMITER)) {
get_token();
result = Level1();
if(token != ')')
serror(1);
get_token();
} else
result = primitive();
return result

}

function primitive()
{
var slot = 0;
var result = 0.0;
var sValue = '';
var i = 0;
switch(tok_type) {
case VARIABLE :
if(typeof oForm[token] == "undefined")
result = 0.0;
else {
switch (oForm[token].tagName) {
case 'INPUT' :
sValue = oForm[token].value;
while(sValue.charAt(i) == ' ') ++i;
if(sValue.charAt(i) == '$') ++i;
sValue = sValue.substr(i,sValue.length-i);
if (!isNumber(sValue)) serror(4);
result = parseFloat(sValue);
if (isNaN(result)) result = 0;
break;
case 'SELECT' :
sValue = oForm[token].options[oForm[token].selectedIndex].value;
while(sValue.charAt(i) == ' ') ++i;
if(sValue.charAt(i) == '$') ++i;
sValue = sValue.substr(i,sValue.length-i);
if (!isNumber(sValue)) serror(0);
result = parseFloat(sValue);
if (isNaN(result)) result = 0;
break;
default:
if( oForm[token].length > 0 ) {
for(i=0; i < oForm[token].length; i++) {
if(oForm[token].checked) {
sValue = oForm[token].value;
while(sValue.charAt(i) == ' ') ++i;
if(sValue.charAt(i) == '$') ++i;
sValue = sValue.substr(i,sValue.length-i);
if (!isNumber(sValue)) serror(4);
isNaN(parseFloat(sValue)) ? result += 0 : result +=
parseFloat(sValue);
var sType = oForm[token].type.toLowerCase();
sType = sType.toLowerCase();
if (sType == 'radio') break;
}
}
}
break;
}
}
get_token();
return result;
case NUMBER:
result = parseFloat(token);
get_token();
return result;
default:
return result;
}
}

// do the math functions
function arith(o,r,h)
{
var t = 0.0;
var ex = 0.0;
switch(o) {
case '-':
r = r - h;
break;
case '+':
r = r + h;
break;
case '*':
r = r * h;
break;
case '/':
r = r / h;
break;
case '%':
t = ((r) / (h));
r = r - (t*(h));
break;
case '^':
ex = r;
if(h==0) {
r = 1.0;
break;
}
for(t=h-1; t>0; --t) r = (r) * ex; // brute force
break;
}
return r;
}

function unary(o, r)
{
if(o=='-') r = -(r);
return r;
}

// return a token to its resting place
function putback()
{
var t = '';

t = token;
for(;t;t++) progIndex--;
}

// find the value of a variable
function find_var(s)
{
var temp = '';

temp = oForm.s.value // if not defined then zero
if( temp == '' ) {
return(0.0);
}
return parseFloat(temp);
}

function serror(error)
{

var e = new Array;

e[0] = "Syntax error";
e[1] = "Unbalanced parentheses";
e[2] = "no expression present";
e[3] = "Form field does not exist " + token;
e[4] = "Not a number"

alert(e[error] + ' - ' + token);

}

function get_token()
{
var temp = '';
tok_type = 0;

while(prog.charAt(progIndex) == ' ') ++progIndex; // skip spaces
if(is_in(prog.charAt(progIndex), "+-*/%^=()")) {
tok_type = DELIMITER;
temp += prog.charAt(progIndex++);
} else if(isAlpha(prog.charAt(progIndex)) || prog.charAt(progIndex) == '$')
{
while(!isdelim(prog.charAt(progIndex))) temp += prog.charAt(progIndex++);
tok_type = VARIABLE;
} else if (isDigit(prog.charAt(progIndex)) || prog.charAt(progIndex) ==
'.') {
while(!isdelim(prog.charAt(progIndex)))
temp += prog.charAt(progIndex++);
tok_type = NUMBER;
}
//--temp;
//while(isspace(temp)) --temp ;
token = temp;

}

// test for delimiter
function isdelim(c)
{
if(is_in(c, "+-/*%^=() ") || c=='\t' || c=='\r')
return 1;
return 0;
}

//test for alpha
function isAlpha(c) {
var sAlpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
if (is_in(c,sAlpha)) return 1; else return 0;
}

function isDigit(c) {
var Digits = '0123456789';
if (is_in(c,Digits)) return 1; else return 0;
}

function isNumber(s) {
var dec = 0;
var i = 0;
if(s.charAt(i) == '-' || s.charAt(i) == '+') ++i;
for(i; i<s.length; i++) {
if(!isDigit(s.charAt(i))) {
if (s.charAt(i) != '.' || dec )
return 0;
else
++dec;
}
}
return 1;
}

function is_in(ch,s)
{
if(s.indexOf(ch) > -1) return 1; else return 0;
}

function round(number,places) {
number = Math.round(number*Math.pow(10,places))/Math.pow(10,places);
number += '';
var x = number.lastIndexOf('.');
if (x == -1 && places > 0) { number += '.'; x = number.length -1; }
for ( i = ((number.length-1) - x); i < places; i++) number += '0';
return prepend ? '$' + number : number;
}


--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

I disagree you can protect your source from the average consumer that does
not require a browser plugin or dongle.

On the following page the implementation script for Form Calculator is
protected. The same can be done to protect the HTML of the web page.

http://www.websunlimited.com/order/Product/FormCalc/formcalc.htm

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible



Murray said:
It is possible to protect HTML but very very time consuming.

The only way I know of is to require the visitor to download and install a
browser plugin, or to use a hardware dongle. In other words, there is no
practical way to do it, at least not in our use space.

--
Murray

ASP scripting is automatically protected.

It is possible to protect HTML but very very time consuming.

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible

How do I protect my source codes? ASP as well as HTML?

 
M

MD Websunlimited

You bet!

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible

Kevin Spencer said:
Challenge me, Mike! ;-)

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

MD Websunlimited said:
Kevin, Murry,

Oops, I was in a hurry to set it up. Let me see what I did wrong.

Like I said it can be time consuming.

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible

Hi Mike,

Is this the protected script?

[formcalc.asp]

var token = ''; // holds the token found
var prog = '';
var progIndex = 0;
var oForm;
var places = 2;
var prepend = 0;
var DELIMITER = 1;
var VARIABLE = 2;
var NUMBER = 3;
var TOKEN_SIZE = 32;
var TRUE = -1;
var FALSE = 0;

function Expression(theForm,theExpression,Places,Prepend) {
places = Places;
prepend = Prepend;
progIndex = 0;
prog = theExpression;
oForm = theForm;
get_token();
if(!token) {
serror(2);
}

Level1();
}

// process an assignment statement
function Level1()
{

var slot;
var ttok_type;
var temp_token;
var result = 0.0;


if(tok_type == VARIABLE) {
// save old token
temp_token = token;
ttok_type = tok_type;
if(typeof oForm[token] != "undefined" ) {
slot = oForm[token];
} else {
serror(3);
}
get_token();
if(token != '=') {
putback();
token = temp_token;
tok_type = ttok_type;
} else {
get_token();
result = Level2();
slot.value = round(result,places);
return;
}
}
result = Level2();
return result;
}

function Level2()
{
var op = '';
var hold = 0;
var result = 0;

result = Level3();
while((op = token) == '+' || op == '-') {
get_token();
hold = Level3();
result = arith(op,result, hold);
}
return result;
}

// multiply or divide two terms
function Level3()
{
var op = '';
var hold = 0;
var result = 0.0;
result = Level4();
while((op = token) == '*' || op == '/') {
get_token();
hold = Level4();
result = arith(op,result, hold);
}
return result;
}

// process integer expoent
function Level4()
{
var hold = 0;
var result = 0;

result = Level5();
if((token) == '^') {
get_token();
hold = Level4();
result = arith('^',result, hold);
}
return result;
}

// unary + or -
function Level5()
{
var op = '';
var result = 0.0;

op = 0;

if((tok_type==DELIMITER) && token == '+' || token == '-') {
op = token;
get_token();
}
result = Level6();
if(op)
result = unary(op,result);
return result;
}

// process parenthesized expression
function Level6()
{
var result = 0.0;

if((token == '(') && (tok_type == DELIMITER)) {
get_token();
result = Level1();
if(token != ')')
serror(1);
get_token();
} else
result = primitive();
return result

}

function primitive()
{
var slot = 0;
var result = 0.0;
var sValue = '';
var i = 0;
switch(tok_type) {
case VARIABLE :
if(typeof oForm[token] == "undefined")
result = 0.0;
else {
switch (oForm[token].tagName) {
case 'INPUT' :
sValue = oForm[token].value;
while(sValue.charAt(i) == ' ') ++i;
if(sValue.charAt(i) == '$') ++i;
sValue = sValue.substr(i,sValue.length-i);
if (!isNumber(sValue)) serror(4);
result = parseFloat(sValue);
if (isNaN(result)) result = 0;
break;
case 'SELECT' :
sValue = oForm[token].options[oForm[token].selectedIndex].value;
while(sValue.charAt(i) == ' ') ++i;
if(sValue.charAt(i) == '$') ++i;
sValue = sValue.substr(i,sValue.length-i);
if (!isNumber(sValue)) serror(0);
result = parseFloat(sValue);
if (isNaN(result)) result = 0;
break;
default:
if( oForm[token].length > 0 ) {
for(i=0; i < oForm[token].length; i++) {
if(oForm[token].checked) {
sValue = oForm[token].value;
while(sValue.charAt(i) == ' ') ++i;
if(sValue.charAt(i) == '$') ++i;
sValue = sValue.substr(i,sValue.length-i);
if (!isNumber(sValue)) serror(4);
isNaN(parseFloat(sValue)) ? result += 0 : result +=
parseFloat(sValue);
var sType = oForm[token].type.toLowerCase();
sType = sType.toLowerCase();
if (sType == 'radio') break;
}
}
}
break;
}
}
get_token();
return result;
case NUMBER:
result = parseFloat(token);
get_token();
return result;
default:
return result;
}
}

// do the math functions
function arith(o,r,h)
{
var t = 0.0;
var ex = 0.0;
switch(o) {
case '-':
r = r - h;
break;
case '+':
r = r + h;
break;
case '*':
r = r * h;
break;
case '/':
r = r / h;
break;
case '%':
t = ((r) / (h));
r = r - (t*(h));
break;
case '^':
ex = r;
if(h==0) {
r = 1.0;
break;
}
for(t=h-1; t>0; --t) r = (r) * ex; // brute force
break;
}
return r;
}

function unary(o, r)
{
if(o=='-') r = -(r);
return r;
}

// return a token to its resting place
function putback()
{
var t = '';

t = token;
for(;t;t++) progIndex--;
}

// find the value of a variable
function find_var(s)
{
var temp = '';

temp = oForm.s.value // if not defined then zero
if( temp == '' ) {
return(0.0);
}
return parseFloat(temp);
}

function serror(error)
{

var e = new Array;

e[0] = "Syntax error";
e[1] = "Unbalanced parentheses";
e[2] = "no expression present";
e[3] = "Form field does not exist " + token;
e[4] = "Not a number"

alert(e[error] + ' - ' + token);

}

function get_token()
{
var temp = '';
tok_type = 0;

while(prog.charAt(progIndex) == ' ') ++progIndex; // skip spaces
if(is_in(prog.charAt(progIndex), "+-*/%^=()")) {
tok_type = DELIMITER;
temp += prog.charAt(progIndex++);
} else if(isAlpha(prog.charAt(progIndex)) || prog.charAt(progIndex) == '$')
{
while(!isdelim(prog.charAt(progIndex))) temp += prog.charAt(progIndex++);
tok_type = VARIABLE;
} else if (isDigit(prog.charAt(progIndex)) || prog.charAt(progIndex) ==
'.') {
while(!isdelim(prog.charAt(progIndex)))
temp += prog.charAt(progIndex++);
tok_type = NUMBER;
}
//--temp;
//while(isspace(temp)) --temp ;
token = temp;

}

// test for delimiter
function isdelim(c)
{
if(is_in(c, "+-/*%^=() ") || c=='\t' || c=='\r')
return 1;
return 0;
}

//test for alpha
function isAlpha(c) {
var sAlpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
if (is_in(c,sAlpha)) return 1; else return 0;
}

function isDigit(c) {
var Digits = '0123456789';
if (is_in(c,Digits)) return 1; else return 0;
}

function isNumber(s) {
var dec = 0;
var i = 0;
if(s.charAt(i) == '-' || s.charAt(i) == '+') ++i;
for(i; i<s.length; i++) {
if(!isDigit(s.charAt(i))) {
if (s.charAt(i) != '.' || dec )
return 0;
else
++dec;
}
}
return 1;
}

function is_in(ch,s)
{
if(s.indexOf(ch) > -1) return 1; else return 0;
}

function round(number,places) {
number = Math.round(number*Math.pow(10,places))/Math.pow(10,places);
number += '';
var x = number.lastIndexOf('.');
if (x == -1 && places > 0) { number += '.'; x = number.length -1; }
for ( i = ((number.length-1) - x); i < places; i++) number += '0';
return prepend ? '$' + number : number;
}


--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

I disagree you can protect your source from the average consumer that does
not require a browser plugin or dongle.

On the following page the implementation script for Form Calculator is
protected. The same can be done to protect the HTML of the web page.

http://www.websunlimited.com/order/Product/FormCalc/formcalc.htm

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible



It is possible to protect HTML but very very time consuming.

The only way I know of is to require the visitor to download and install a
browser plugin, or to use a hardware dongle. In other words, there is no
practical way to do it, at least not in our use space.

--
Murray

ASP scripting is automatically protected.

It is possible to protect HTML but very very time consuming.

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible

How do I protect my source codes? ASP as well as HTML?


 
M

Murray

8)

Good thing we caught this for you. Invoice is in the mail!

--
Murray

MD Websunlimited said:
You bet!

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible

Kevin Spencer said:
Challenge me, Mike! ;-)

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

MD Websunlimited said:
Kevin, Murry,

Oops, I was in a hurry to set it up. Let me see what I did wrong.

Like I said it can be time consuming.

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible

Hi Mike,

Is this the protected script?

[formcalc.asp]

var token = ''; // holds the token found
var prog = '';
var progIndex = 0;
var oForm;
var places = 2;
var prepend = 0;
var DELIMITER = 1;
var VARIABLE = 2;
var NUMBER = 3;
var TOKEN_SIZE = 32;
var TRUE = -1;
var FALSE = 0;

function Expression(theForm,theExpression,Places,Prepend) {
places = Places;
prepend = Prepend;
progIndex = 0;
prog = theExpression;
oForm = theForm;
get_token();
if(!token) {
serror(2);
}

Level1();
}

// process an assignment statement
function Level1()
{

var slot;
var ttok_type;
var temp_token;
var result = 0.0;


if(tok_type == VARIABLE) {
// save old token
temp_token = token;
ttok_type = tok_type;
if(typeof oForm[token] != "undefined" ) {
slot = oForm[token];
} else {
serror(3);
}
get_token();
if(token != '=') {
putback();
token = temp_token;
tok_type = ttok_type;
} else {
get_token();
result = Level2();
slot.value = round(result,places);
return;
}
}
result = Level2();
return result;
}

function Level2()
{
var op = '';
var hold = 0;
var result = 0;

result = Level3();
while((op = token) == '+' || op == '-') {
get_token();
hold = Level3();
result = arith(op,result, hold);
}
return result;
}

// multiply or divide two terms
function Level3()
{
var op = '';
var hold = 0;
var result = 0.0;
result = Level4();
while((op = token) == '*' || op == '/') {
get_token();
hold = Level4();
result = arith(op,result, hold);
}
return result;
}

// process integer expoent
function Level4()
{
var hold = 0;
var result = 0;

result = Level5();
if((token) == '^') {
get_token();
hold = Level4();
result = arith('^',result, hold);
}
return result;
}

// unary + or -
function Level5()
{
var op = '';
var result = 0.0;

op = 0;

if((tok_type==DELIMITER) && token == '+' || token == '-') {
op = token;
get_token();
}
result = Level6();
if(op)
result = unary(op,result);
return result;
}

// process parenthesized expression
function Level6()
{
var result = 0.0;

if((token == '(') && (tok_type == DELIMITER)) {
get_token();
result = Level1();
if(token != ')')
serror(1);
get_token();
} else
result = primitive();
return result

}

function primitive()
{
var slot = 0;
var result = 0.0;
var sValue = '';
var i = 0;
switch(tok_type) {
case VARIABLE :
if(typeof oForm[token] == "undefined")
result = 0.0;
else {
switch (oForm[token].tagName) {
case 'INPUT' :
sValue = oForm[token].value;
while(sValue.charAt(i) == ' ') ++i;
if(sValue.charAt(i) == '$') ++i;
sValue = sValue.substr(i,sValue.length-i);
if (!isNumber(sValue)) serror(4);
result = parseFloat(sValue);
if (isNaN(result)) result = 0;
break;
case 'SELECT' :
sValue = oForm[token].options[oForm[token].selectedIndex].value;
while(sValue.charAt(i) == ' ') ++i;
if(sValue.charAt(i) == '$') ++i;
sValue = sValue.substr(i,sValue.length-i);
if (!isNumber(sValue)) serror(0);
result = parseFloat(sValue);
if (isNaN(result)) result = 0;
break;
default:
if( oForm[token].length > 0 ) {
for(i=0; i < oForm[token].length; i++) {
if(oForm[token].checked) {
sValue = oForm[token].value;
while(sValue.charAt(i) == ' ') ++i;
if(sValue.charAt(i) == '$') ++i;
sValue = sValue.substr(i,sValue.length-i);
if (!isNumber(sValue)) serror(4);
isNaN(parseFloat(sValue)) ? result += 0 : result +=
parseFloat(sValue);
var sType = oForm[token].type.toLowerCase();
sType = sType.toLowerCase();
if (sType == 'radio') break;
}
}
}
break;
}
}
get_token();
return result;
case NUMBER:
result = parseFloat(token);
get_token();
return result;
default:
return result;
}
}

// do the math functions
function arith(o,r,h)
{
var t = 0.0;
var ex = 0.0;
switch(o) {
case '-':
r = r - h;
break;
case '+':
r = r + h;
break;
case '*':
r = r * h;
break;
case '/':
r = r / h;
break;
case '%':
t = ((r) / (h));
r = r - (t*(h));
break;
case '^':
ex = r;
if(h==0) {
r = 1.0;
break;
}
for(t=h-1; t>0; --t) r = (r) * ex; // brute force
break;
}
return r;
}

function unary(o, r)
{
if(o=='-') r = -(r);
return r;
}

// return a token to its resting place
function putback()
{
var t = '';

t = token;
for(;t;t++) progIndex--;
}

// find the value of a variable
function find_var(s)
{
var temp = '';

temp = oForm.s.value // if not defined then zero
if( temp == '' ) {
return(0.0);
}
return parseFloat(temp);
}

function serror(error)
{

var e = new Array;

e[0] = "Syntax error";
e[1] = "Unbalanced parentheses";
e[2] = "no expression present";
e[3] = "Form field does not exist " + token;
e[4] = "Not a number"

alert(e[error] + ' - ' + token);

}

function get_token()
{
var temp = '';
tok_type = 0;

while(prog.charAt(progIndex) == ' ') ++progIndex; // skip spaces
if(is_in(prog.charAt(progIndex), "+-*/%^=()")) {
tok_type = DELIMITER;
temp += prog.charAt(progIndex++);
} else if(isAlpha(prog.charAt(progIndex)) || prog.charAt(progIndex)
== '$')
{
while(!isdelim(prog.charAt(progIndex))) temp += prog.charAt(progIndex++);
tok_type = VARIABLE;
} else if (isDigit(prog.charAt(progIndex)) || prog.charAt(progIndex)
==
'.') {
while(!isdelim(prog.charAt(progIndex)))
temp += prog.charAt(progIndex++);
tok_type = NUMBER;
}
//--temp;
//while(isspace(temp)) --temp ;
token = temp;

}

// test for delimiter
function isdelim(c)
{
if(is_in(c, "+-/*%^=() ") || c=='\t' || c=='\r')
return 1;
return 0;
}

//test for alpha
function isAlpha(c) {
var sAlpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
if (is_in(c,sAlpha)) return 1; else return 0;
}

function isDigit(c) {
var Digits = '0123456789';
if (is_in(c,Digits)) return 1; else return 0;
}

function isNumber(s) {
var dec = 0;
var i = 0;
if(s.charAt(i) == '-' || s.charAt(i) == '+') ++i;
for(i; i<s.length; i++) {
if(!isDigit(s.charAt(i))) {
if (s.charAt(i) != '.' || dec )
return 0;
else
++dec;
}
}
return 1;
}

function is_in(ch,s)
{
if(s.indexOf(ch) > -1) return 1; else return 0;
}

function round(number,places) {
number =
Math.round(number*Math.pow(10,places))/Math.pow(10,places);
number += '';
var x = number.lastIndexOf('.');
if (x == -1 && places > 0) { number += '.'; x = number.length -1; }
for ( i = ((number.length-1) - x); i < places; i++) number += '0';
return prepend ? '$' + number : number;
}


--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

I disagree you can protect your source from the average consumer that does
not require a browser plugin or dongle.

On the following page the implementation script for Form Calculator
is
protected. The same can be done to protect the HTML of the web page.

http://www.websunlimited.com/order/Product/FormCalc/formcalc.htm

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible



It is possible to protect HTML but very very time consuming.

The only way I know of is to require the visitor to download and install a
browser plugin, or to use a hardware dongle. In other words, there
is no
practical way to do it, at least not in our use space.

--
Murray

ASP scripting is automatically protected.

It is possible to protect HTML but very very time consuming.

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible

How do I protect my source codes? ASP as well as HTML?


 
M

MD Websunlimited

Here is your protected source page:

http://www.websunlimited.com/samples/no_source_view.htm


--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible


MD Websunlimited said:
You bet!

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible

Kevin Spencer said:
Challenge me, Mike! ;-)

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

MD Websunlimited said:
Kevin, Murry,

Oops, I was in a hurry to set it up. Let me see what I did wrong.

Like I said it can be time consuming.

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible

Hi Mike,

Is this the protected script?

[formcalc.asp]

var token = ''; // holds the token found
var prog = '';
var progIndex = 0;
var oForm;
var places = 2;
var prepend = 0;
var DELIMITER = 1;
var VARIABLE = 2;
var NUMBER = 3;
var TOKEN_SIZE = 32;
var TRUE = -1;
var FALSE = 0;

function Expression(theForm,theExpression,Places,Prepend) {
places = Places;
prepend = Prepend;
progIndex = 0;
prog = theExpression;
oForm = theForm;
get_token();
if(!token) {
serror(2);
}

Level1();
}

// process an assignment statement
function Level1()
{

var slot;
var ttok_type;
var temp_token;
var result = 0.0;


if(tok_type == VARIABLE) {
// save old token
temp_token = token;
ttok_type = tok_type;
if(typeof oForm[token] != "undefined" ) {
slot = oForm[token];
} else {
serror(3);
}
get_token();
if(token != '=') {
putback();
token = temp_token;
tok_type = ttok_type;
} else {
get_token();
result = Level2();
slot.value = round(result,places);
return;
}
}
result = Level2();
return result;
}

function Level2()
{
var op = '';
var hold = 0;
var result = 0;

result = Level3();
while((op = token) == '+' || op == '-') {
get_token();
hold = Level3();
result = arith(op,result, hold);
}
return result;
}

// multiply or divide two terms
function Level3()
{
var op = '';
var hold = 0;
var result = 0.0;
result = Level4();
while((op = token) == '*' || op == '/') {
get_token();
hold = Level4();
result = arith(op,result, hold);
}
return result;
}

// process integer expoent
function Level4()
{
var hold = 0;
var result = 0;

result = Level5();
if((token) == '^') {
get_token();
hold = Level4();
result = arith('^',result, hold);
}
return result;
}

// unary + or -
function Level5()
{
var op = '';
var result = 0.0;

op = 0;

if((tok_type==DELIMITER) && token == '+' || token == '-') {
op = token;
get_token();
}
result = Level6();
if(op)
result = unary(op,result);
return result;
}

// process parenthesized expression
function Level6()
{
var result = 0.0;

if((token == '(') && (tok_type == DELIMITER)) {
get_token();
result = Level1();
if(token != ')')
serror(1);
get_token();
} else
result = primitive();
return result

}

function primitive()
{
var slot = 0;
var result = 0.0;
var sValue = '';
var i = 0;
switch(tok_type) {
case VARIABLE :
if(typeof oForm[token] == "undefined")
result = 0.0;
else {
switch (oForm[token].tagName) {
case 'INPUT' :
sValue = oForm[token].value;
while(sValue.charAt(i) == ' ') ++i;
if(sValue.charAt(i) == '$') ++i;
sValue = sValue.substr(i,sValue.length-i);
if (!isNumber(sValue)) serror(4);
result = parseFloat(sValue);
if (isNaN(result)) result = 0;
break;
case 'SELECT' :
sValue = oForm[token].options[oForm[token].selectedIndex].value;
while(sValue.charAt(i) == ' ') ++i;
if(sValue.charAt(i) == '$') ++i;
sValue = sValue.substr(i,sValue.length-i);
if (!isNumber(sValue)) serror(0);
result = parseFloat(sValue);
if (isNaN(result)) result = 0;
break;
default:
if( oForm[token].length > 0 ) {
for(i=0; i < oForm[token].length; i++) {
if(oForm[token].checked) {
sValue = oForm[token].value;
while(sValue.charAt(i) == ' ') ++i;
if(sValue.charAt(i) == '$') ++i;
sValue = sValue.substr(i,sValue.length-i);
if (!isNumber(sValue)) serror(4);
isNaN(parseFloat(sValue)) ? result += 0 : result +=
parseFloat(sValue);
var sType = oForm[token].type.toLowerCase();
sType = sType.toLowerCase();
if (sType == 'radio') break;
}
}
}
break;
}
}
get_token();
return result;
case NUMBER:
result = parseFloat(token);
get_token();
return result;
default:
return result;
}
}

// do the math functions
function arith(o,r,h)
{
var t = 0.0;
var ex = 0.0;
switch(o) {
case '-':
r = r - h;
break;
case '+':
r = r + h;
break;
case '*':
r = r * h;
break;
case '/':
r = r / h;
break;
case '%':
t = ((r) / (h));
r = r - (t*(h));
break;
case '^':
ex = r;
if(h==0) {
r = 1.0;
break;
}
for(t=h-1; t>0; --t) r = (r) * ex; // brute force
break;
}
return r;
}

function unary(o, r)
{
if(o=='-') r = -(r);
return r;
}

// return a token to its resting place
function putback()
{
var t = '';

t = token;
for(;t;t++) progIndex--;
}

// find the value of a variable
function find_var(s)
{
var temp = '';

temp = oForm.s.value // if not defined then zero
if( temp == '' ) {
return(0.0);
}
return parseFloat(temp);
}

function serror(error)
{

var e = new Array;

e[0] = "Syntax error";
e[1] = "Unbalanced parentheses";
e[2] = "no expression present";
e[3] = "Form field does not exist " + token;
e[4] = "Not a number"

alert(e[error] + ' - ' + token);

}

function get_token()
{
var temp = '';
tok_type = 0;

while(prog.charAt(progIndex) == ' ') ++progIndex; // skip spaces
if(is_in(prog.charAt(progIndex), "+-*/%^=()")) {
tok_type = DELIMITER;
temp += prog.charAt(progIndex++);
} else if(isAlpha(prog.charAt(progIndex)) || prog.charAt(progIndex) == '$')
{
while(!isdelim(prog.charAt(progIndex))) temp += prog.charAt(progIndex++);
tok_type = VARIABLE;
} else if (isDigit(prog.charAt(progIndex)) || prog.charAt(progIndex) ==
'.') {
while(!isdelim(prog.charAt(progIndex)))
temp += prog.charAt(progIndex++);
tok_type = NUMBER;
}
//--temp;
//while(isspace(temp)) --temp ;
token = temp;

}

// test for delimiter
function isdelim(c)
{
if(is_in(c, "+-/*%^=() ") || c=='\t' || c=='\r')
return 1;
return 0;
}

//test for alpha
function isAlpha(c) {
var sAlpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
if (is_in(c,sAlpha)) return 1; else return 0;
}

function isDigit(c) {
var Digits = '0123456789';
if (is_in(c,Digits)) return 1; else return 0;
}

function isNumber(s) {
var dec = 0;
var i = 0;
if(s.charAt(i) == '-' || s.charAt(i) == '+') ++i;
for(i; i<s.length; i++) {
if(!isDigit(s.charAt(i))) {
if (s.charAt(i) != '.' || dec )
return 0;
else
++dec;
}
}
return 1;
}

function is_in(ch,s)
{
if(s.indexOf(ch) > -1) return 1; else return 0;
}

function round(number,places) {
number = Math.round(number*Math.pow(10,places))/Math.pow(10,places);
number += '';
var x = number.lastIndexOf('.');
if (x == -1 && places > 0) { number += '.'; x = number.length -1; }
for ( i = ((number.length-1) - x); i < places; i++) number += '0';
return prepend ? '$' + number : number;
}


--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

I disagree you can protect your source from the average consumer that does
not require a browser plugin or dongle.

On the following page the implementation script for Form Calculator is
protected. The same can be done to protect the HTML of the web page.

http://www.websunlimited.com/order/Product/FormCalc/formcalc.htm

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible



It is possible to protect HTML but very very time consuming.

The only way I know of is to require the visitor to download and install a
browser plugin, or to use a hardware dongle. In other words, there is no
practical way to do it, at least not in our use space.

--
Murray

ASP scripting is automatically protected.

It is possible to protect HTML but very very time consuming.

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible

How do I protect my source codes? ASP as well as HTML?


 
M

MD Websunlimited

Oh okay. It was nice of Kevin to publish it all ;>)

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible

Murray said:
8)

Good thing we caught this for you. Invoice is in the mail!

--
Murray

MD Websunlimited said:
You bet!

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible

Kevin Spencer said:
Challenge me, Mike! ;-)

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

Kevin, Murry,

Oops, I was in a hurry to set it up. Let me see what I did wrong.

Like I said it can be time consuming.

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible

Hi Mike,

Is this the protected script?

[formcalc.asp]

var token = ''; // holds the token found
var prog = '';
var progIndex = 0;
var oForm;
var places = 2;
var prepend = 0;
var DELIMITER = 1;
var VARIABLE = 2;
var NUMBER = 3;
var TOKEN_SIZE = 32;
var TRUE = -1;
var FALSE = 0;

function Expression(theForm,theExpression,Places,Prepend) {
places = Places;
prepend = Prepend;
progIndex = 0;
prog = theExpression;
oForm = theForm;
get_token();
if(!token) {
serror(2);
}

Level1();
}

// process an assignment statement
function Level1()
{

var slot;
var ttok_type;
var temp_token;
var result = 0.0;


if(tok_type == VARIABLE) {
// save old token
temp_token = token;
ttok_type = tok_type;
if(typeof oForm[token] != "undefined" ) {
slot = oForm[token];
} else {
serror(3);
}
get_token();
if(token != '=') {
putback();
token = temp_token;
tok_type = ttok_type;
} else {
get_token();
result = Level2();
slot.value = round(result,places);
return;
}
}
result = Level2();
return result;
}

function Level2()
{
var op = '';
var hold = 0;
var result = 0;

result = Level3();
while((op = token) == '+' || op == '-') {
get_token();
hold = Level3();
result = arith(op,result, hold);
}
return result;
}

// multiply or divide two terms
function Level3()
{
var op = '';
var hold = 0;
var result = 0.0;
result = Level4();
while((op = token) == '*' || op == '/') {
get_token();
hold = Level4();
result = arith(op,result, hold);
}
return result;
}

// process integer expoent
function Level4()
{
var hold = 0;
var result = 0;

result = Level5();
if((token) == '^') {
get_token();
hold = Level4();
result = arith('^',result, hold);
}
return result;
}

// unary + or -
function Level5()
{
var op = '';
var result = 0.0;

op = 0;

if((tok_type==DELIMITER) && token == '+' || token == '-') {
op = token;
get_token();
}
result = Level6();
if(op)
result = unary(op,result);
return result;
}

// process parenthesized expression
function Level6()
{
var result = 0.0;

if((token == '(') && (tok_type == DELIMITER)) {
get_token();
result = Level1();
if(token != ')')
serror(1);
get_token();
} else
result = primitive();
return result

}

function primitive()
{
var slot = 0;
var result = 0.0;
var sValue = '';
var i = 0;
switch(tok_type) {
case VARIABLE :
if(typeof oForm[token] == "undefined")
result = 0.0;
else {
switch (oForm[token].tagName) {
case 'INPUT' :
sValue = oForm[token].value;
while(sValue.charAt(i) == ' ') ++i;
if(sValue.charAt(i) == '$') ++i;
sValue = sValue.substr(i,sValue.length-i);
if (!isNumber(sValue)) serror(4);
result = parseFloat(sValue);
if (isNaN(result)) result = 0;
break;
case 'SELECT' :
sValue = oForm[token].options[oForm[token].selectedIndex].value;
while(sValue.charAt(i) == ' ') ++i;
if(sValue.charAt(i) == '$') ++i;
sValue = sValue.substr(i,sValue.length-i);
if (!isNumber(sValue)) serror(0);
result = parseFloat(sValue);
if (isNaN(result)) result = 0;
break;
default:
if( oForm[token].length > 0 ) {
for(i=0; i < oForm[token].length; i++) {
if(oForm[token].checked) {
sValue = oForm[token].value;
while(sValue.charAt(i) == ' ') ++i;
if(sValue.charAt(i) == '$') ++i;
sValue = sValue.substr(i,sValue.length-i);
if (!isNumber(sValue)) serror(4);
isNaN(parseFloat(sValue)) ? result += 0 : result +=
parseFloat(sValue);
var sType = oForm[token].type.toLowerCase();
sType = sType.toLowerCase();
if (sType == 'radio') break;
}
}
}
break;
}
}
get_token();
return result;
case NUMBER:
result = parseFloat(token);
get_token();
return result;
default:
return result;
}
}

// do the math functions
function arith(o,r,h)
{
var t = 0.0;
var ex = 0.0;
switch(o) {
case '-':
r = r - h;
break;
case '+':
r = r + h;
break;
case '*':
r = r * h;
break;
case '/':
r = r / h;
break;
case '%':
t = ((r) / (h));
r = r - (t*(h));
break;
case '^':
ex = r;
if(h==0) {
r = 1.0;
break;
}
for(t=h-1; t>0; --t) r = (r) * ex; // brute force
break;
}
return r;
}

function unary(o, r)
{
if(o=='-') r = -(r);
return r;
}

// return a token to its resting place
function putback()
{
var t = '';

t = token;
for(;t;t++) progIndex--;
}

// find the value of a variable
function find_var(s)
{
var temp = '';

temp = oForm.s.value // if not defined then zero
if( temp == '' ) {
return(0.0);
}
return parseFloat(temp);
}

function serror(error)
{

var e = new Array;

e[0] = "Syntax error";
e[1] = "Unbalanced parentheses";
e[2] = "no expression present";
e[3] = "Form field does not exist " + token;
e[4] = "Not a number"

alert(e[error] + ' - ' + token);

}

function get_token()
{
var temp = '';
tok_type = 0;

while(prog.charAt(progIndex) == ' ') ++progIndex; // skip spaces
if(is_in(prog.charAt(progIndex), "+-*/%^=()")) {
tok_type = DELIMITER;
temp += prog.charAt(progIndex++);
} else if(isAlpha(prog.charAt(progIndex)) || prog.charAt(progIndex)
==
'$')
{
while(!isdelim(prog.charAt(progIndex))) temp +=
prog.charAt(progIndex++);
tok_type = VARIABLE;
} else if (isDigit(prog.charAt(progIndex)) || prog.charAt(progIndex)
==
'.') {
while(!isdelim(prog.charAt(progIndex)))
temp += prog.charAt(progIndex++);
tok_type = NUMBER;
}
//--temp;
//while(isspace(temp)) --temp ;
token = temp;

}

// test for delimiter
function isdelim(c)
{
if(is_in(c, "+-/*%^=() ") || c=='\t' || c=='\r')
return 1;
return 0;
}

//test for alpha
function isAlpha(c) {
var sAlpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
if (is_in(c,sAlpha)) return 1; else return 0;
}

function isDigit(c) {
var Digits = '0123456789';
if (is_in(c,Digits)) return 1; else return 0;
}

function isNumber(s) {
var dec = 0;
var i = 0;
if(s.charAt(i) == '-' || s.charAt(i) == '+') ++i;
for(i; i<s.length; i++) {
if(!isDigit(s.charAt(i))) {
if (s.charAt(i) != '.' || dec )
return 0;
else
++dec;
}
}
return 1;
}

function is_in(ch,s)
{
if(s.indexOf(ch) > -1) return 1; else return 0;
}

function round(number,places) {
number =
Math.round(number*Math.pow(10,places))/Math.pow(10,places);
number += '';
var x = number.lastIndexOf('.');
if (x == -1 && places > 0) { number += '.'; x = number.length -1; }
for ( i = ((number.length-1) - x); i < places; i++) number += '0';
return prepend ? '$' + number : number;
}


--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

I disagree you can protect your source from the average consumer that
does
not require a browser plugin or dongle.

On the following page the implementation script for Form Calculator
is
protected. The same can be done to protect the HTML of the web page.

http://www.websunlimited.com/order/Product/FormCalc/formcalc.htm

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible



It is possible to protect HTML but very very time consuming.

The only way I know of is to require the visitor to download and
install a
browser plugin, or to use a hardware dongle. In other words, there
is
no
practical way to do it, at least not in our use space.

--
Murray

ASP scripting is automatically protected.

It is possible to protect HTML but very very time consuming.

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible

How do I protect my source codes? ASP as well as HTML?


 
K

Kevin Spencer

Hi Mike,

Sorry about publishing your other JavaScript. I don't think you'll mind if I
publish this one:

document.write('<table border="1" width="100%" id="table1">');
document.write('<tr>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('</tr>');
document.write('<tr>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('</tr>');
document.write('<tr>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('</tr>');
document.write('<tr>');
document.write('<td>&nbsp;</td>');
document.write('<td>');
document.write('<p align="center">This pages source HTML is protected from
viewing</td>');
document.write('<td>&nbsp;</td>');
document.write('</tr>');
document.write('<tr>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('</tr>');
document.write('<tr>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('</tr>');
document.write('<tr>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('</tr>');
document.write('</table>');
document.write('<p align="center">');
document.write('<img border="0" src="images/cab_bus_columns1.gif" width="56"
height="56"></p>');
document.write('');

In case anyone is interested, here's how I did it: I cleaned out my
Temporary Internet Files folder to make it easier to find stuff. Then I
opened your page. After that, I opened Notepad, browsed my temporary Intenet
files folder, and dragged "nosource.asp" to the NotePad instance. Voila!

Interestingly, if I requested "nosource.asp" in the browser, I got a message
stating that it was protected, and in Temporary Internet files, there were
TWO "nosource.asp" files, one containing the message, and the other with the
code. How you did that, Mike, I don't know. But I DO know how to view your
source code! ;-)

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

MD Websunlimited said:
Here is your protected source page:

http://www.websunlimited.com/samples/no_source_view.htm


--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible


You bet!

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible

Challenge me, Mike! ;-)

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

Kevin, Murry,

Oops, I was in a hurry to set it up. Let me see what I did wrong.

Like I said it can be time consuming.

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible

Hi Mike,

Is this the protected script?

[formcalc.asp]

var token = ''; // holds the token found
var prog = '';
var progIndex = 0;
var oForm;
var places = 2;
var prepend = 0;
var DELIMITER = 1;
var VARIABLE = 2;
var NUMBER = 3;
var TOKEN_SIZE = 32;
var TRUE = -1;
var FALSE = 0;

function Expression(theForm,theExpression,Places,Prepend) {
places = Places;
prepend = Prepend;
progIndex = 0;
prog = theExpression;
oForm = theForm;
get_token();
if(!token) {
serror(2);
}

Level1();
}

// process an assignment statement
function Level1()
{

var slot;
var ttok_type;
var temp_token;
var result = 0.0;


if(tok_type == VARIABLE) {
// save old token
temp_token = token;
ttok_type = tok_type;
if(typeof oForm[token] != "undefined" ) {
slot = oForm[token];
} else {
serror(3);
}
get_token();
if(token != '=') {
putback();
token = temp_token;
tok_type = ttok_type;
} else {
get_token();
result = Level2();
slot.value = round(result,places);
return;
}
}
result = Level2();
return result;
}

function Level2()
{
var op = '';
var hold = 0;
var result = 0;

result = Level3();
while((op = token) == '+' || op == '-') {
get_token();
hold = Level3();
result = arith(op,result, hold);
}
return result;
}

// multiply or divide two terms
function Level3()
{
var op = '';
var hold = 0;
var result = 0.0;
result = Level4();
while((op = token) == '*' || op == '/') {
get_token();
hold = Level4();
result = arith(op,result, hold);
}
return result;
}

// process integer expoent
function Level4()
{
var hold = 0;
var result = 0;

result = Level5();
if((token) == '^') {
get_token();
hold = Level4();
result = arith('^',result, hold);
}
return result;
}

// unary + or -
function Level5()
{
var op = '';
var result = 0.0;

op = 0;

if((tok_type==DELIMITER) && token == '+' || token == '-') {
op = token;
get_token();
}
result = Level6();
if(op)
result = unary(op,result);
return result;
}

// process parenthesized expression
function Level6()
{
var result = 0.0;

if((token == '(') && (tok_type == DELIMITER)) {
get_token();
result = Level1();
if(token != ')')
serror(1);
get_token();
} else
result = primitive();
return result

}

function primitive()
{
var slot = 0;
var result = 0.0;
var sValue = '';
var i = 0;
switch(tok_type) {
case VARIABLE :
if(typeof oForm[token] == "undefined")
result = 0.0;
else {
switch (oForm[token].tagName) {
case 'INPUT' :
sValue = oForm[token].value;
while(sValue.charAt(i) == ' ') ++i;
if(sValue.charAt(i) == '$') ++i;
sValue = sValue.substr(i,sValue.length-i);
if (!isNumber(sValue)) serror(4);
result = parseFloat(sValue);
if (isNaN(result)) result = 0;
break;
case 'SELECT' :
sValue = oForm[token].options[oForm[token].selectedIndex].value;
while(sValue.charAt(i) == ' ') ++i;
if(sValue.charAt(i) == '$') ++i;
sValue = sValue.substr(i,sValue.length-i);
if (!isNumber(sValue)) serror(0);
result = parseFloat(sValue);
if (isNaN(result)) result = 0;
break;
default:
if( oForm[token].length > 0 ) {
for(i=0; i < oForm[token].length; i++) {
if(oForm[token].checked) {
sValue = oForm[token].value;
while(sValue.charAt(i) == ' ') ++i;
if(sValue.charAt(i) == '$') ++i;
sValue = sValue.substr(i,sValue.length-i);
if (!isNumber(sValue)) serror(4);
isNaN(parseFloat(sValue)) ? result += 0 : result +=
parseFloat(sValue);
var sType = oForm[token].type.toLowerCase();
sType = sType.toLowerCase();
if (sType == 'radio') break;
}
}
}
break;
}
}
get_token();
return result;
case NUMBER:
result = parseFloat(token);
get_token();
return result;
default:
return result;
}
}

// do the math functions
function arith(o,r,h)
{
var t = 0.0;
var ex = 0.0;
switch(o) {
case '-':
r = r - h;
break;
case '+':
r = r + h;
break;
case '*':
r = r * h;
break;
case '/':
r = r / h;
break;
case '%':
t = ((r) / (h));
r = r - (t*(h));
break;
case '^':
ex = r;
if(h==0) {
r = 1.0;
break;
}
for(t=h-1; t>0; --t) r = (r) * ex; // brute force
break;
}
return r;
}

function unary(o, r)
{
if(o=='-') r = -(r);
return r;
}

// return a token to its resting place
function putback()
{
var t = '';

t = token;
for(;t;t++) progIndex--;
}

// find the value of a variable
function find_var(s)
{
var temp = '';

temp = oForm.s.value // if not defined then zero
if( temp == '' ) {
return(0.0);
}
return parseFloat(temp);
}

function serror(error)
{

var e = new Array;

e[0] = "Syntax error";
e[1] = "Unbalanced parentheses";
e[2] = "no expression present";
e[3] = "Form field does not exist " + token;
e[4] = "Not a number"

alert(e[error] + ' - ' + token);

}

function get_token()
{
var temp = '';
tok_type = 0;

while(prog.charAt(progIndex) == ' ') ++progIndex; // skip spaces
if(is_in(prog.charAt(progIndex), "+-*/%^=()")) {
tok_type = DELIMITER;
temp += prog.charAt(progIndex++);
} else if(isAlpha(prog.charAt(progIndex)) || prog.charAt(progIndex) ==
'$')
{
while(!isdelim(prog.charAt(progIndex))) temp +=
prog.charAt(progIndex++);
tok_type = VARIABLE;
} else if (isDigit(prog.charAt(progIndex)) || prog.charAt(progIndex) ==
'.') {
while(!isdelim(prog.charAt(progIndex)))
temp += prog.charAt(progIndex++);
tok_type = NUMBER;
}
//--temp;
//while(isspace(temp)) --temp ;
token = temp;

}

// test for delimiter
function isdelim(c)
{
if(is_in(c, "+-/*%^=() ") || c=='\t' || c=='\r')
return 1;
return 0;
}

//test for alpha
function isAlpha(c) {
var sAlpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
if (is_in(c,sAlpha)) return 1; else return 0;
}

function isDigit(c) {
var Digits = '0123456789';
if (is_in(c,Digits)) return 1; else return 0;
}

function isNumber(s) {
var dec = 0;
var i = 0;
if(s.charAt(i) == '-' || s.charAt(i) == '+') ++i;
for(i; i<s.length; i++) {
if(!isDigit(s.charAt(i))) {
if (s.charAt(i) != '.' || dec )
return 0;
else
++dec;
}
}
return 1;
}

function is_in(ch,s)
{
if(s.indexOf(ch) > -1) return 1; else return 0;
}

function round(number,places) {
number = Math.round(number*Math.pow(10,places))/Math.pow(10,places);
number += '';
var x = number.lastIndexOf('.');
if (x == -1 && places > 0) { number += '.'; x = number.length -1; }
for ( i = ((number.length-1) - x); i < places; i++) number += '0';
return prepend ? '$' + number : number;
}


--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

I disagree you can protect your source from the average consumer that
does
not require a browser plugin or dongle.

On the following page the implementation script for Form Calculator is
protected. The same can be done to protect the HTML of the web page.

http://www.websunlimited.com/order/Product/FormCalc/formcalc.htm

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible



It is possible to protect HTML but very very time consuming.

The only way I know of is to require the visitor to download and
install a
browser plugin, or to use a hardware dongle. In other words, there is
no
practical way to do it, at least not in our use space.

--
Murray

ASP scripting is automatically protected.

It is possible to protect HTML but very very time consuming.

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible

How do I protect my source codes? ASP as well as HTML?


 
M

Murray

I got it. It's in there ---> <script src="nosource.asp">

8)

--
Murray

MD Websunlimited said:
Here is your protected source page:

http://www.websunlimited.com/samples/no_source_view.htm


--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible


MD Websunlimited said:
You bet!

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible

Kevin Spencer said:
Challenge me, Mike! ;-)

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

Kevin, Murry,

Oops, I was in a hurry to set it up. Let me see what I did wrong.

Like I said it can be time consuming.

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible

Hi Mike,

Is this the protected script?

[formcalc.asp]

var token = ''; // holds the token found
var prog = '';
var progIndex = 0;
var oForm;
var places = 2;
var prepend = 0;
var DELIMITER = 1;
var VARIABLE = 2;
var NUMBER = 3;
var TOKEN_SIZE = 32;
var TRUE = -1;
var FALSE = 0;

function Expression(theForm,theExpression,Places,Prepend) {
places = Places;
prepend = Prepend;
progIndex = 0;
prog = theExpression;
oForm = theForm;
get_token();
if(!token) {
serror(2);
}

Level1();
}

// process an assignment statement
function Level1()
{

var slot;
var ttok_type;
var temp_token;
var result = 0.0;


if(tok_type == VARIABLE) {
// save old token
temp_token = token;
ttok_type = tok_type;
if(typeof oForm[token] != "undefined" ) {
slot = oForm[token];
} else {
serror(3);
}
get_token();
if(token != '=') {
putback();
token = temp_token;
tok_type = ttok_type;
} else {
get_token();
result = Level2();
slot.value = round(result,places);
return;
}
}
result = Level2();
return result;
}

function Level2()
{
var op = '';
var hold = 0;
var result = 0;

result = Level3();
while((op = token) == '+' || op == '-') {
get_token();
hold = Level3();
result = arith(op,result, hold);
}
return result;
}

// multiply or divide two terms
function Level3()
{
var op = '';
var hold = 0;
var result = 0.0;
result = Level4();
while((op = token) == '*' || op == '/') {
get_token();
hold = Level4();
result = arith(op,result, hold);
}
return result;
}

// process integer expoent
function Level4()
{
var hold = 0;
var result = 0;

result = Level5();
if((token) == '^') {
get_token();
hold = Level4();
result = arith('^',result, hold);
}
return result;
}

// unary + or -
function Level5()
{
var op = '';
var result = 0.0;

op = 0;

if((tok_type==DELIMITER) && token == '+' || token == '-') {
op = token;
get_token();
}
result = Level6();
if(op)
result = unary(op,result);
return result;
}

// process parenthesized expression
function Level6()
{
var result = 0.0;

if((token == '(') && (tok_type == DELIMITER)) {
get_token();
result = Level1();
if(token != ')')
serror(1);
get_token();
} else
result = primitive();
return result

}

function primitive()
{
var slot = 0;
var result = 0.0;
var sValue = '';
var i = 0;
switch(tok_type) {
case VARIABLE :
if(typeof oForm[token] == "undefined")
result = 0.0;
else {
switch (oForm[token].tagName) {
case 'INPUT' :
sValue = oForm[token].value;
while(sValue.charAt(i) == ' ') ++i;
if(sValue.charAt(i) == '$') ++i;
sValue = sValue.substr(i,sValue.length-i);
if (!isNumber(sValue)) serror(4);
result = parseFloat(sValue);
if (isNaN(result)) result = 0;
break;
case 'SELECT' :
sValue =
oForm[token].options[oForm[token].selectedIndex].value;
while(sValue.charAt(i) == ' ') ++i;
if(sValue.charAt(i) == '$') ++i;
sValue = sValue.substr(i,sValue.length-i);
if (!isNumber(sValue)) serror(0);
result = parseFloat(sValue);
if (isNaN(result)) result = 0;
break;
default:
if( oForm[token].length > 0 ) {
for(i=0; i < oForm[token].length; i++) {
if(oForm[token].checked) {
sValue = oForm[token].value;
while(sValue.charAt(i) == ' ') ++i;
if(sValue.charAt(i) == '$') ++i;
sValue = sValue.substr(i,sValue.length-i);
if (!isNumber(sValue)) serror(4);
isNaN(parseFloat(sValue)) ? result += 0 : result +=
parseFloat(sValue);
var sType = oForm[token].type.toLowerCase();
sType = sType.toLowerCase();
if (sType == 'radio') break;
}
}
}
break;
}
}
get_token();
return result;
case NUMBER:
result = parseFloat(token);
get_token();
return result;
default:
return result;
}
}

// do the math functions
function arith(o,r,h)
{
var t = 0.0;
var ex = 0.0;
switch(o) {
case '-':
r = r - h;
break;
case '+':
r = r + h;
break;
case '*':
r = r * h;
break;
case '/':
r = r / h;
break;
case '%':
t = ((r) / (h));
r = r - (t*(h));
break;
case '^':
ex = r;
if(h==0) {
r = 1.0;
break;
}
for(t=h-1; t>0; --t) r = (r) * ex; // brute force
break;
}
return r;
}

function unary(o, r)
{
if(o=='-') r = -(r);
return r;
}

// return a token to its resting place
function putback()
{
var t = '';

t = token;
for(;t;t++) progIndex--;
}

// find the value of a variable
function find_var(s)
{
var temp = '';

temp = oForm.s.value // if not defined then zero
if( temp == '' ) {
return(0.0);
}
return parseFloat(temp);
}

function serror(error)
{

var e = new Array;

e[0] = "Syntax error";
e[1] = "Unbalanced parentheses";
e[2] = "no expression present";
e[3] = "Form field does not exist " + token;
e[4] = "Not a number"

alert(e[error] + ' - ' + token);

}

function get_token()
{
var temp = '';
tok_type = 0;

while(prog.charAt(progIndex) == ' ') ++progIndex; // skip spaces
if(is_in(prog.charAt(progIndex), "+-*/%^=()")) {
tok_type = DELIMITER;
temp += prog.charAt(progIndex++);
} else if(isAlpha(prog.charAt(progIndex)) ||
prog.charAt(progIndex) ==
'$')
{
while(!isdelim(prog.charAt(progIndex))) temp +=
prog.charAt(progIndex++);
tok_type = VARIABLE;
} else if (isDigit(prog.charAt(progIndex)) ||
prog.charAt(progIndex) ==
'.') {
while(!isdelim(prog.charAt(progIndex)))
temp += prog.charAt(progIndex++);
tok_type = NUMBER;
}
//--temp;
//while(isspace(temp)) --temp ;
token = temp;

}

// test for delimiter
function isdelim(c)
{
if(is_in(c, "+-/*%^=() ") || c=='\t' || c=='\r')
return 1;
return 0;
}

//test for alpha
function isAlpha(c) {
var sAlpha =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
if (is_in(c,sAlpha)) return 1; else return 0;
}

function isDigit(c) {
var Digits = '0123456789';
if (is_in(c,Digits)) return 1; else return 0;
}

function isNumber(s) {
var dec = 0;
var i = 0;
if(s.charAt(i) == '-' || s.charAt(i) == '+') ++i;
for(i; i<s.length; i++) {
if(!isDigit(s.charAt(i))) {
if (s.charAt(i) != '.' || dec )
return 0;
else
++dec;
}
}
return 1;
}

function is_in(ch,s)
{
if(s.indexOf(ch) > -1) return 1; else return 0;
}

function round(number,places) {
number =
Math.round(number*Math.pow(10,places))/Math.pow(10,places);
number += '';
var x = number.lastIndexOf('.');
if (x == -1 && places > 0) { number += '.'; x =
number.length -1; }
for ( i = ((number.length-1) - x); i < places; i++) number += '0';
return prepend ? '$' + number : number;
}


--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

I disagree you can protect your source from the average consumer
that
does
not require a browser plugin or dongle.

On the following page the implementation script for Form Calculator
is
protected. The same can be done to protect the HTML of the web
page.

http://www.websunlimited.com/order/Product/FormCalc/formcalc.htm

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible



It is possible to protect HTML but very very time consuming.

The only way I know of is to require the visitor to download and
install a
browser plugin, or to use a hardware dongle. In other words,
there is
no
practical way to do it, at least not in our use space.

--
Murray

ASP scripting is automatically protected.

It is possible to protect HTML but very very time consuming.

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible

How do I protect my source codes? ASP as well as HTML?


 
M

MD Websunlimited

Kevin,

I have a hunch you're using a sniffer and not just using the browser. I assume you have access to one at your work location.
;>)

Recall, I prefaced this with "average consumer".

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible



Kevin Spencer said:
Hi Mike,

Sorry about publishing your other JavaScript. I don't think you'll mind if I
publish this one:

document.write('<table border="1" width="100%" id="table1">');
document.write('<tr>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('</tr>');
document.write('<tr>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('</tr>');
document.write('<tr>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('</tr>');
document.write('<tr>');
document.write('<td>&nbsp;</td>');
document.write('<td>');
document.write('<p align="center">This pages source HTML is protected from
viewing</td>');
document.write('<td>&nbsp;</td>');
document.write('</tr>');
document.write('<tr>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('</tr>');
document.write('<tr>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('</tr>');
document.write('<tr>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('</tr>');
document.write('</table>');
document.write('<p align="center">');
document.write('<img border="0" src="images/cab_bus_columns1.gif" width="56"
height="56"></p>');
document.write('');

In case anyone is interested, here's how I did it: I cleaned out my
Temporary Internet Files folder to make it easier to find stuff. Then I
opened your page. After that, I opened Notepad, browsed my temporary Intenet
files folder, and dragged "nosource.asp" to the NotePad instance. Voila!

Interestingly, if I requested "nosource.asp" in the browser, I got a message
stating that it was protected, and in Temporary Internet files, there were
TWO "nosource.asp" files, one containing the message, and the other with the
code. How you did that, Mike, I don't know. But I DO know how to view your
source code! ;-)

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

MD Websunlimited said:
Here is your protected source page:

http://www.websunlimited.com/samples/no_source_view.htm


--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible


You bet!

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible

Challenge me, Mike! ;-)

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

Kevin, Murry,

Oops, I was in a hurry to set it up. Let me see what I did wrong.

Like I said it can be time consuming.

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible

Hi Mike,

Is this the protected script?

[formcalc.asp]

var token = ''; // holds the token found
var prog = '';
var progIndex = 0;
var oForm;
var places = 2;
var prepend = 0;
var DELIMITER = 1;
var VARIABLE = 2;
var NUMBER = 3;
var TOKEN_SIZE = 32;
var TRUE = -1;
var FALSE = 0;

function Expression(theForm,theExpression,Places,Prepend) {
places = Places;
prepend = Prepend;
progIndex = 0;
prog = theExpression;
oForm = theForm;
get_token();
if(!token) {
serror(2);
}

Level1();
}

// process an assignment statement
function Level1()
{

var slot;
var ttok_type;
var temp_token;
var result = 0.0;


if(tok_type == VARIABLE) {
// save old token
temp_token = token;
ttok_type = tok_type;
if(typeof oForm[token] != "undefined" ) {
slot = oForm[token];
} else {
serror(3);
}
get_token();
if(token != '=') {
putback();
token = temp_token;
tok_type = ttok_type;
} else {
get_token();
result = Level2();
slot.value = round(result,places);
return;
}
}
result = Level2();
return result;
}

function Level2()
{
var op = '';
var hold = 0;
var result = 0;

result = Level3();
while((op = token) == '+' || op == '-') {
get_token();
hold = Level3();
result = arith(op,result, hold);
}
return result;
}

// multiply or divide two terms
function Level3()
{
var op = '';
var hold = 0;
var result = 0.0;
result = Level4();
while((op = token) == '*' || op == '/') {
get_token();
hold = Level4();
result = arith(op,result, hold);
}
return result;
}

// process integer expoent
function Level4()
{
var hold = 0;
var result = 0;

result = Level5();
if((token) == '^') {
get_token();
hold = Level4();
result = arith('^',result, hold);
}
return result;
}

// unary + or -
function Level5()
{
var op = '';
var result = 0.0;

op = 0;

if((tok_type==DELIMITER) && token == '+' || token == '-') {
op = token;
get_token();
}
result = Level6();
if(op)
result = unary(op,result);
return result;
}

// process parenthesized expression
function Level6()
{
var result = 0.0;

if((token == '(') && (tok_type == DELIMITER)) {
get_token();
result = Level1();
if(token != ')')
serror(1);
get_token();
} else
result = primitive();
return result

}

function primitive()
{
var slot = 0;
var result = 0.0;
var sValue = '';
var i = 0;
switch(tok_type) {
case VARIABLE :
if(typeof oForm[token] == "undefined")
result = 0.0;
else {
switch (oForm[token].tagName) {
case 'INPUT' :
sValue = oForm[token].value;
while(sValue.charAt(i) == ' ') ++i;
if(sValue.charAt(i) == '$') ++i;
sValue = sValue.substr(i,sValue.length-i);
if (!isNumber(sValue)) serror(4);
result = parseFloat(sValue);
if (isNaN(result)) result = 0;
break;
case 'SELECT' :
sValue = oForm[token].options[oForm[token].selectedIndex].value;
while(sValue.charAt(i) == ' ') ++i;
if(sValue.charAt(i) == '$') ++i;
sValue = sValue.substr(i,sValue.length-i);
if (!isNumber(sValue)) serror(0);
result = parseFloat(sValue);
if (isNaN(result)) result = 0;
break;
default:
if( oForm[token].length > 0 ) {
for(i=0; i < oForm[token].length; i++) {
if(oForm[token].checked) {
sValue = oForm[token].value;
while(sValue.charAt(i) == ' ') ++i;
if(sValue.charAt(i) == '$') ++i;
sValue = sValue.substr(i,sValue.length-i);
if (!isNumber(sValue)) serror(4);
isNaN(parseFloat(sValue)) ? result += 0 : result +=
parseFloat(sValue);
var sType = oForm[token].type.toLowerCase();
sType = sType.toLowerCase();
if (sType == 'radio') break;
}
}
}
break;
}
}
get_token();
return result;
case NUMBER:
result = parseFloat(token);
get_token();
return result;
default:
return result;
}
}

// do the math functions
function arith(o,r,h)
{
var t = 0.0;
var ex = 0.0;
switch(o) {
case '-':
r = r - h;
break;
case '+':
r = r + h;
break;
case '*':
r = r * h;
break;
case '/':
r = r / h;
break;
case '%':
t = ((r) / (h));
r = r - (t*(h));
break;
case '^':
ex = r;
if(h==0) {
r = 1.0;
break;
}
for(t=h-1; t>0; --t) r = (r) * ex; // brute force
break;
}
return r;
}

function unary(o, r)
{
if(o=='-') r = -(r);
return r;
}

// return a token to its resting place
function putback()
{
var t = '';

t = token;
for(;t;t++) progIndex--;
}

// find the value of a variable
function find_var(s)
{
var temp = '';

temp = oForm.s.value // if not defined then zero
if( temp == '' ) {
return(0.0);
}
return parseFloat(temp);
}

function serror(error)
{

var e = new Array;

e[0] = "Syntax error";
e[1] = "Unbalanced parentheses";
e[2] = "no expression present";
e[3] = "Form field does not exist " + token;
e[4] = "Not a number"

alert(e[error] + ' - ' + token);

}

function get_token()
{
var temp = '';
tok_type = 0;

while(prog.charAt(progIndex) == ' ') ++progIndex; // skip spaces
if(is_in(prog.charAt(progIndex), "+-*/%^=()")) {
tok_type = DELIMITER;
temp += prog.charAt(progIndex++);
} else if(isAlpha(prog.charAt(progIndex)) || prog.charAt(progIndex) ==
'$')
{
while(!isdelim(prog.charAt(progIndex))) temp +=
prog.charAt(progIndex++);
tok_type = VARIABLE;
} else if (isDigit(prog.charAt(progIndex)) || prog.charAt(progIndex) ==
'.') {
while(!isdelim(prog.charAt(progIndex)))
temp += prog.charAt(progIndex++);
tok_type = NUMBER;
}
//--temp;
//while(isspace(temp)) --temp ;
token = temp;

}

// test for delimiter
function isdelim(c)
{
if(is_in(c, "+-/*%^=() ") || c=='\t' || c=='\r')
return 1;
return 0;
}

//test for alpha
function isAlpha(c) {
var sAlpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
if (is_in(c,sAlpha)) return 1; else return 0;
}

function isDigit(c) {
var Digits = '0123456789';
if (is_in(c,Digits)) return 1; else return 0;
}

function isNumber(s) {
var dec = 0;
var i = 0;
if(s.charAt(i) == '-' || s.charAt(i) == '+') ++i;
for(i; i<s.length; i++) {
if(!isDigit(s.charAt(i))) {
if (s.charAt(i) != '.' || dec )
return 0;
else
++dec;
}
}
return 1;
}

function is_in(ch,s)
{
if(s.indexOf(ch) > -1) return 1; else return 0;
}

function round(number,places) {
number = Math.round(number*Math.pow(10,places))/Math.pow(10,places);
number += '';
var x = number.lastIndexOf('.');
if (x == -1 && places > 0) { number += '.'; x = number.length -1; }
for ( i = ((number.length-1) - x); i < places; i++) number += '0';
return prepend ? '$' + number : number;
}


--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

I disagree you can protect your source from the average consumer that
does
not require a browser plugin or dongle.

On the following page the implementation script for Form Calculator is
protected. The same can be done to protect the HTML of the web page.

http://www.websunlimited.com/order/Product/FormCalc/formcalc.htm

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible



It is possible to protect HTML but very very time consuming.

The only way I know of is to require the visitor to download and
install a
browser plugin, or to use a hardware dongle. In other words, there is
no
practical way to do it, at least not in our use space.

--
Murray

ASP scripting is automatically protected.

It is possible to protect HTML but very very time consuming.

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible

How do I protect my source codes? ASP as well as HTML?


 
K

Kevin Spencer

Hi Mike,

Actually, no. I did it just as I described. However, I have not been able to
duplicate my earlier results since. The "nosource.asp" file doesn't even
show up. Did you change something?

In any case, congratulations are in order! I'm sure if I spent enough time
on it, I could figure it out, but I believe your technique would deter
anyone but a highly-experienced programmer. Now, all you have to do is sell
it!

--
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

MD Websunlimited said:
Kevin,

I have a hunch you're using a sniffer and not just using the browser. I
assume you have access to one at your work location.
;>)

Recall, I prefaced this with "average consumer".

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible



Hi Mike,

Sorry about publishing your other JavaScript. I don't think you'll mind if I
publish this one:

document.write('<table border="1" width="100%" id="table1">');
document.write('<tr>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('</tr>');
document.write('<tr>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('</tr>');
document.write('<tr>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('</tr>');
document.write('<tr>');
document.write('<td>&nbsp;</td>');
document.write('<td>');
document.write('<p align="center">This pages source HTML is protected from
viewing</td>');
document.write('<td>&nbsp;</td>');
document.write('</tr>');
document.write('<tr>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('</tr>');
document.write('<tr>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('</tr>');
document.write('<tr>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('</tr>');
document.write('</table>');
document.write('<p align="center">');
document.write('<img border="0" src="images/cab_bus_columns1.gif" width="56"
height="56"></p>');
document.write('');

In case anyone is interested, here's how I did it: I cleaned out my
Temporary Internet Files folder to make it easier to find stuff. Then I
opened your page. After that, I opened Notepad, browsed my temporary Intenet
files folder, and dragged "nosource.asp" to the NotePad instance. Voila!

Interestingly, if I requested "nosource.asp" in the browser, I got a message
stating that it was protected, and in Temporary Internet files, there were
TWO "nosource.asp" files, one containing the message, and the other with the
code. How you did that, Mike, I don't know. But I DO know how to view your
source code! ;-)

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

MD Websunlimited said:
Here is your protected source page:

http://www.websunlimited.com/samples/no_source_view.htm


--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible


You bet!

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible

Challenge me, Mike! ;-)

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

Kevin, Murry,

Oops, I was in a hurry to set it up. Let me see what I did wrong.

Like I said it can be time consuming.

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible

Hi Mike,

Is this the protected script?

[formcalc.asp]

var token = ''; // holds the token found
var prog = '';
var progIndex = 0;
var oForm;
var places = 2;
var prepend = 0;
var DELIMITER = 1;
var VARIABLE = 2;
var NUMBER = 3;
var TOKEN_SIZE = 32;
var TRUE = -1;
var FALSE = 0;

function Expression(theForm,theExpression,Places,Prepend) {
places = Places;
prepend = Prepend;
progIndex = 0;
prog = theExpression;
oForm = theForm;
get_token();
if(!token) {
serror(2);
}

Level1();
}

// process an assignment statement
function Level1()
{

var slot;
var ttok_type;
var temp_token;
var result = 0.0;


if(tok_type == VARIABLE) {
// save old token
temp_token = token;
ttok_type = tok_type;
if(typeof oForm[token] != "undefined" ) {
slot = oForm[token];
} else {
serror(3);
}
get_token();
if(token != '=') {
putback();
token = temp_token;
tok_type = ttok_type;
} else {
get_token();
result = Level2();
slot.value = round(result,places);
return;
}
}
result = Level2();
return result;
}

function Level2()
{
var op = '';
var hold = 0;
var result = 0;

result = Level3();
while((op = token) == '+' || op == '-') {
get_token();
hold = Level3();
result = arith(op,result, hold);
}
return result;
}

// multiply or divide two terms
function Level3()
{
var op = '';
var hold = 0;
var result = 0.0;
result = Level4();
while((op = token) == '*' || op == '/') {
get_token();
hold = Level4();
result = arith(op,result, hold);
}
return result;
}

// process integer expoent
function Level4()
{
var hold = 0;
var result = 0;

result = Level5();
if((token) == '^') {
get_token();
hold = Level4();
result = arith('^',result, hold);
}
return result;
}

// unary + or -
function Level5()
{
var op = '';
var result = 0.0;

op = 0;

if((tok_type==DELIMITER) && token == '+' || token == '-') {
op = token;
get_token();
}
result = Level6();
if(op)
result = unary(op,result);
return result;
}

// process parenthesized expression
function Level6()
{
var result = 0.0;

if((token == '(') && (tok_type == DELIMITER)) {
get_token();
result = Level1();
if(token != ')')
serror(1);
get_token();
} else
result = primitive();
return result

}

function primitive()
{
var slot = 0;
var result = 0.0;
var sValue = '';
var i = 0;
switch(tok_type) {
case VARIABLE :
if(typeof oForm[token] == "undefined")
result = 0.0;
else {
switch (oForm[token].tagName) {
case 'INPUT' :
sValue = oForm[token].value;
while(sValue.charAt(i) == ' ') ++i;
if(sValue.charAt(i) == '$') ++i;
sValue = sValue.substr(i,sValue.length-i);
if (!isNumber(sValue)) serror(4);
result = parseFloat(sValue);
if (isNaN(result)) result = 0;
break;
case 'SELECT' :
sValue = oForm[token].options[oForm[token].selectedIndex].value;
while(sValue.charAt(i) == ' ') ++i;
if(sValue.charAt(i) == '$') ++i;
sValue = sValue.substr(i,sValue.length-i);
if (!isNumber(sValue)) serror(0);
result = parseFloat(sValue);
if (isNaN(result)) result = 0;
break;
default:
if( oForm[token].length > 0 ) {
for(i=0; i < oForm[token].length; i++) {
if(oForm[token].checked) {
sValue = oForm[token].value;
while(sValue.charAt(i) == ' ') ++i;
if(sValue.charAt(i) == '$') ++i;
sValue = sValue.substr(i,sValue.length-i);
if (!isNumber(sValue)) serror(4);
isNaN(parseFloat(sValue)) ? result += 0 : result +=
parseFloat(sValue);
var sType = oForm[token].type.toLowerCase();
sType = sType.toLowerCase();
if (sType == 'radio') break;
}
}
}
break;
}
}
get_token();
return result;
case NUMBER:
result = parseFloat(token);
get_token();
return result;
default:
return result;
}
}

// do the math functions
function arith(o,r,h)
{
var t = 0.0;
var ex = 0.0;
switch(o) {
case '-':
r = r - h;
break;
case '+':
r = r + h;
break;
case '*':
r = r * h;
break;
case '/':
r = r / h;
break;
case '%':
t = ((r) / (h));
r = r - (t*(h));
break;
case '^':
ex = r;
if(h==0) {
r = 1.0;
break;
}
for(t=h-1; t>0; --t) r = (r) * ex; // brute force
break;
}
return r;
}

function unary(o, r)
{
if(o=='-') r = -(r);
return r;
}

// return a token to its resting place
function putback()
{
var t = '';

t = token;
for(;t;t++) progIndex--;
}

// find the value of a variable
function find_var(s)
{
var temp = '';

temp = oForm.s.value // if not defined then zero
if( temp == '' ) {
return(0.0);
}
return parseFloat(temp);
}

function serror(error)
{

var e = new Array;

e[0] = "Syntax error";
e[1] = "Unbalanced parentheses";
e[2] = "no expression present";
e[3] = "Form field does not exist " + token;
e[4] = "Not a number"

alert(e[error] + ' - ' + token);

}

function get_token()
{
var temp = '';
tok_type = 0;

while(prog.charAt(progIndex) == ' ') ++progIndex; // skip spaces
if(is_in(prog.charAt(progIndex), "+-*/%^=()")) {
tok_type = DELIMITER;
temp += prog.charAt(progIndex++);
} else if(isAlpha(prog.charAt(progIndex)) || prog.charAt(progIndex) ==
'$')
{
while(!isdelim(prog.charAt(progIndex))) temp +=
prog.charAt(progIndex++);
tok_type = VARIABLE;
} else if (isDigit(prog.charAt(progIndex)) || prog.charAt(progIndex) ==
'.') {
while(!isdelim(prog.charAt(progIndex)))
temp += prog.charAt(progIndex++);
tok_type = NUMBER;
}
//--temp;
//while(isspace(temp)) --temp ;
token = temp;

}

// test for delimiter
function isdelim(c)
{
if(is_in(c, "+-/*%^=() ") || c=='\t' || c=='\r')
return 1;
return 0;
}

//test for alpha
function isAlpha(c) {
var sAlpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
if (is_in(c,sAlpha)) return 1; else return 0;
}

function isDigit(c) {
var Digits = '0123456789';
if (is_in(c,Digits)) return 1; else return 0;
}

function isNumber(s) {
var dec = 0;
var i = 0;
if(s.charAt(i) == '-' || s.charAt(i) == '+') ++i;
for(i; i<s.length; i++) {
if(!isDigit(s.charAt(i))) {
if (s.charAt(i) != '.' || dec )
return 0;
else
++dec;
}
}
return 1;
}

function is_in(ch,s)
{
if(s.indexOf(ch) > -1) return 1; else return 0;
}

function round(number,places) {
number = Math.round(number*Math.pow(10,places))/Math.pow(10,places);
number += '';
var x = number.lastIndexOf('.');
if (x == -1 && places > 0) { number += '.'; x = number.length -1; }
for ( i = ((number.length-1) - x); i < places; i++) number += '0';
return prepend ? '$' + number : number;
}


--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

I disagree you can protect your source from the average
consumer
that
does
not require a browser plugin or dongle.

On the following page the implementation script for Form Calculator is
protected. The same can be done to protect the HTML of the web page.

http://www.websunlimited.com/order/Product/FormCalc/formcalc.htm

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible



It is possible to protect HTML but very very time consuming.

The only way I know of is to require the visitor to download and
install a
browser plugin, or to use a hardware dongle. In other
words,
there is
no
practical way to do it, at least not in our use space.

--
Murray

ASP scripting is automatically protected.

It is possible to protect HTML but very very time consuming.

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible

How do I protect my source codes? ASP as well as HTML?

 
M

MD Websunlimited

Kevin,

I didn't fully read your message in my post, sorry. So I tried your technique and I do not get the nosource.asp file in my temp
files.

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible

Kevin Spencer said:
Hi Mike,

Sorry about publishing your other JavaScript. I don't think you'll mind if I
publish this one:

document.write('<table border="1" width="100%" id="table1">');
document.write('<tr>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('</tr>');
document.write('<tr>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('</tr>');
document.write('<tr>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('</tr>');
document.write('<tr>');
document.write('<td>&nbsp;</td>');
document.write('<td>');
document.write('<p align="center">This pages source HTML is protected from
viewing</td>');
document.write('<td>&nbsp;</td>');
document.write('</tr>');
document.write('<tr>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('</tr>');
document.write('<tr>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('</tr>');
document.write('<tr>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('<td>&nbsp;</td>');
document.write('</tr>');
document.write('</table>');
document.write('<p align="center">');
document.write('<img border="0" src="images/cab_bus_columns1.gif" width="56"
height="56"></p>');
document.write('');

In case anyone is interested, here's how I did it: I cleaned out my
Temporary Internet Files folder to make it easier to find stuff. Then I
opened your page. After that, I opened Notepad, browsed my temporary Intenet
files folder, and dragged "nosource.asp" to the NotePad instance. Voila!

Interestingly, if I requested "nosource.asp" in the browser, I got a message
stating that it was protected, and in Temporary Internet files, there were
TWO "nosource.asp" files, one containing the message, and the other with the
code. How you did that, Mike, I don't know. But I DO know how to view your
source code! ;-)

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

MD Websunlimited said:
Here is your protected source page:

http://www.websunlimited.com/samples/no_source_view.htm


--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible


You bet!

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible

Challenge me, Mike! ;-)

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

Kevin, Murry,

Oops, I was in a hurry to set it up. Let me see what I did wrong.

Like I said it can be time consuming.

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible

Hi Mike,

Is this the protected script?

[formcalc.asp]

var token = ''; // holds the token found
var prog = '';
var progIndex = 0;
var oForm;
var places = 2;
var prepend = 0;
var DELIMITER = 1;
var VARIABLE = 2;
var NUMBER = 3;
var TOKEN_SIZE = 32;
var TRUE = -1;
var FALSE = 0;

function Expression(theForm,theExpression,Places,Prepend) {
places = Places;
prepend = Prepend;
progIndex = 0;
prog = theExpression;
oForm = theForm;
get_token();
if(!token) {
serror(2);
}

Level1();
}

// process an assignment statement
function Level1()
{

var slot;
var ttok_type;
var temp_token;
var result = 0.0;


if(tok_type == VARIABLE) {
// save old token
temp_token = token;
ttok_type = tok_type;
if(typeof oForm[token] != "undefined" ) {
slot = oForm[token];
} else {
serror(3);
}
get_token();
if(token != '=') {
putback();
token = temp_token;
tok_type = ttok_type;
} else {
get_token();
result = Level2();
slot.value = round(result,places);
return;
}
}
result = Level2();
return result;
}

function Level2()
{
var op = '';
var hold = 0;
var result = 0;

result = Level3();
while((op = token) == '+' || op == '-') {
get_token();
hold = Level3();
result = arith(op,result, hold);
}
return result;
}

// multiply or divide two terms
function Level3()
{
var op = '';
var hold = 0;
var result = 0.0;
result = Level4();
while((op = token) == '*' || op == '/') {
get_token();
hold = Level4();
result = arith(op,result, hold);
}
return result;
}

// process integer expoent
function Level4()
{
var hold = 0;
var result = 0;

result = Level5();
if((token) == '^') {
get_token();
hold = Level4();
result = arith('^',result, hold);
}
return result;
}

// unary + or -
function Level5()
{
var op = '';
var result = 0.0;

op = 0;

if((tok_type==DELIMITER) && token == '+' || token == '-') {
op = token;
get_token();
}
result = Level6();
if(op)
result = unary(op,result);
return result;
}

// process parenthesized expression
function Level6()
{
var result = 0.0;

if((token == '(') && (tok_type == DELIMITER)) {
get_token();
result = Level1();
if(token != ')')
serror(1);
get_token();
} else
result = primitive();
return result

}

function primitive()
{
var slot = 0;
var result = 0.0;
var sValue = '';
var i = 0;
switch(tok_type) {
case VARIABLE :
if(typeof oForm[token] == "undefined")
result = 0.0;
else {
switch (oForm[token].tagName) {
case 'INPUT' :
sValue = oForm[token].value;
while(sValue.charAt(i) == ' ') ++i;
if(sValue.charAt(i) == '$') ++i;
sValue = sValue.substr(i,sValue.length-i);
if (!isNumber(sValue)) serror(4);
result = parseFloat(sValue);
if (isNaN(result)) result = 0;
break;
case 'SELECT' :
sValue = oForm[token].options[oForm[token].selectedIndex].value;
while(sValue.charAt(i) == ' ') ++i;
if(sValue.charAt(i) == '$') ++i;
sValue = sValue.substr(i,sValue.length-i);
if (!isNumber(sValue)) serror(0);
result = parseFloat(sValue);
if (isNaN(result)) result = 0;
break;
default:
if( oForm[token].length > 0 ) {
for(i=0; i < oForm[token].length; i++) {
if(oForm[token].checked) {
sValue = oForm[token].value;
while(sValue.charAt(i) == ' ') ++i;
if(sValue.charAt(i) == '$') ++i;
sValue = sValue.substr(i,sValue.length-i);
if (!isNumber(sValue)) serror(4);
isNaN(parseFloat(sValue)) ? result += 0 : result +=
parseFloat(sValue);
var sType = oForm[token].type.toLowerCase();
sType = sType.toLowerCase();
if (sType == 'radio') break;
}
}
}
break;
}
}
get_token();
return result;
case NUMBER:
result = parseFloat(token);
get_token();
return result;
default:
return result;
}
}

// do the math functions
function arith(o,r,h)
{
var t = 0.0;
var ex = 0.0;
switch(o) {
case '-':
r = r - h;
break;
case '+':
r = r + h;
break;
case '*':
r = r * h;
break;
case '/':
r = r / h;
break;
case '%':
t = ((r) / (h));
r = r - (t*(h));
break;
case '^':
ex = r;
if(h==0) {
r = 1.0;
break;
}
for(t=h-1; t>0; --t) r = (r) * ex; // brute force
break;
}
return r;
}

function unary(o, r)
{
if(o=='-') r = -(r);
return r;
}

// return a token to its resting place
function putback()
{
var t = '';

t = token;
for(;t;t++) progIndex--;
}

// find the value of a variable
function find_var(s)
{
var temp = '';

temp = oForm.s.value // if not defined then zero
if( temp == '' ) {
return(0.0);
}
return parseFloat(temp);
}

function serror(error)
{

var e = new Array;

e[0] = "Syntax error";
e[1] = "Unbalanced parentheses";
e[2] = "no expression present";
e[3] = "Form field does not exist " + token;
e[4] = "Not a number"

alert(e[error] + ' - ' + token);

}

function get_token()
{
var temp = '';
tok_type = 0;

while(prog.charAt(progIndex) == ' ') ++progIndex; // skip spaces
if(is_in(prog.charAt(progIndex), "+-*/%^=()")) {
tok_type = DELIMITER;
temp += prog.charAt(progIndex++);
} else if(isAlpha(prog.charAt(progIndex)) || prog.charAt(progIndex) ==
'$')
{
while(!isdelim(prog.charAt(progIndex))) temp +=
prog.charAt(progIndex++);
tok_type = VARIABLE;
} else if (isDigit(prog.charAt(progIndex)) || prog.charAt(progIndex) ==
'.') {
while(!isdelim(prog.charAt(progIndex)))
temp += prog.charAt(progIndex++);
tok_type = NUMBER;
}
//--temp;
//while(isspace(temp)) --temp ;
token = temp;

}

// test for delimiter
function isdelim(c)
{
if(is_in(c, "+-/*%^=() ") || c=='\t' || c=='\r')
return 1;
return 0;
}

//test for alpha
function isAlpha(c) {
var sAlpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
if (is_in(c,sAlpha)) return 1; else return 0;
}

function isDigit(c) {
var Digits = '0123456789';
if (is_in(c,Digits)) return 1; else return 0;
}

function isNumber(s) {
var dec = 0;
var i = 0;
if(s.charAt(i) == '-' || s.charAt(i) == '+') ++i;
for(i; i<s.length; i++) {
if(!isDigit(s.charAt(i))) {
if (s.charAt(i) != '.' || dec )
return 0;
else
++dec;
}
}
return 1;
}

function is_in(ch,s)
{
if(s.indexOf(ch) > -1) return 1; else return 0;
}

function round(number,places) {
number = Math.round(number*Math.pow(10,places))/Math.pow(10,places);
number += '';
var x = number.lastIndexOf('.');
if (x == -1 && places > 0) { number += '.'; x = number.length -1; }
for ( i = ((number.length-1) - x); i < places; i++) number += '0';
return prepend ? '$' + number : number;
}


--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

I disagree you can protect your source from the average consumer that
does
not require a browser plugin or dongle.

On the following page the implementation script for Form Calculator is
protected. The same can be done to protect the HTML of the web page.

http://www.websunlimited.com/order/Product/FormCalc/formcalc.htm

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible



It is possible to protect HTML but very very time consuming.

The only way I know of is to require the visitor to download and
install a
browser plugin, or to use a hardware dongle. In other words, there is
no
practical way to do it, at least not in our use space.

--
Murray

ASP scripting is automatically protected.

It is possible to protect HTML but very very time consuming.

--
Mike -- FrontPage MVP '97-'02
J-Bots 2004 Released Special Pricing
http://www.websunlimited.com
FrontPage Add-ins Since '97 FP 2003 / 2002 / 2000 Compatible

How do I protect my source codes? ASP as well as HTML?


 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top