Forum Moderators: coopster

Message Too Old, No Replies

Help on where and how to use a PHP script.

I have the script but unsure how to implement it.

         

shawn

7:29 pm on Apr 18, 2003 (gmt 0)

10+ Year Member



Another memenr here was kind enough to point me in the direction of this script. I am trying to use the following script - but unsure how exactly. I tried to use <?php include('csource.php')?> however it does not encrypt the HTML code.

Second - will this mess me up when Google comes to index my page? Right now the google bot comes like clock work every month. I do not want to make page unreadable for the spiders.

Thank You - Shawn :)

<?
// Usage notes:
//
// just put include('csource.php') in the beginning
// of your script. The HTML content will be automatically
// encrypted via Base64 algorithm so nobody can view it.

function _fwk_filter_encrypt($content)
{
$table = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_@";
$xor = 165;

// Prepare encoding table
$table = array_keys(count_chars($table, 1));
$i_min = min($table);
$i_max = max($table);
for ($c = count($table); $c > 0; $r = mt_rand(0, $c--))
array_splice($table, $r, $c - $r, array_reverse(array_slice($table, $r, $c - $r)));

// Encode sequence
$len = strlen($content);
$word = $shift = 0;
for ($i = 0; $i < $len; $i++)
{
$ch = $xor ^ ord($content[$i]);
$word ¦= ($ch << $shift);
$shift = ($shift + 2) % 6;
$enc .= chr($table[$word & 0x3F]);
$word >>= 6;
if (!$shift)
{
$enc .= chr($table[$word]);
$word >>= 6;
}
}
if ($shift)
$enc .= chr($table[$word]);

// Decode sequence
$tbl = array_fill($i_min, $i_max - $i_min + 1, 0);
while (list($k,$v) = each($table))
$tbl[$v] = $k;
$tbl = implode(",", $tbl);

$fi = ",p=0,s=0,w=0,t=Array({$tbl})";
$f = "w¦=(t[x.charCodeAt(p++)-{$i_min}])<<s;";
$f .= "if(s){r+=String.fromCharCode({$xor}^w&255);w>>=8;s-=2}else{s=6}";

// Generate page
$r = "<script language=JavaScript>";
$r.= "function decrypt_p(x){";
$r.= "var l=x.length,b=1024,i,j,r{$fi};";
$r.= "for(j=Math.ceil(l/b);j>0;j--){r='';for(i=Math.min(l,b);i>0;i--,l--){{$f}}document.write(r)}";
$r.= "}decrypt_p(\"{$enc}\")";
$r.= "</script>";
return $r;
}
ob_start("_fwk_filter_encrypt");

?>

[edited by: jatar_k at 12:03 am (utc) on April 19, 2003]
[edit reason] no urls thanks [/edit]

TheWebographer

7:39 pm on Apr 18, 2003 (gmt 0)

10+ Year Member



Personally I cannot see why anyone would want to encrypt their HTML source! Sure, being a newbie you may think your HTML is out of this world and people are going to come from miles around to steal your cleverness. Truth be told an experieced coder can pretty much just look at your site and reproduce it at will.

shawn

7:53 pm on Apr 18, 2003 (gmt 0)

10+ Year Member



Personally I cannot see why anyone would want to encrypt their HTML source! Sure, being a newbie you may think your HTML is out of this world and people are going to come from miles around to steal your cleverness. Truth be told an experieced coder can pretty much just look at your site and reproduce it at will.

It is not that I am a NEWBIE nor do I think my code is "spectacular". There are times when I create demo sites for a client I am trying to secure that I want to hide the code. Why? because there are certain competitors here that I would rather not educate. If you can look at my website and reproduce it without "view source" then kudos - I do not care. But I wont educate my less than savy competitors if I can help it.

So with that aside - I am still looking for an answer - no full of themselves responses.

NeedScripts

8:27 pm on Apr 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Shawn,

I understand your point, and I sure TheWebographer didn't meant it in a wrong way.

About using your php script.

1) Just upload the php script that you are downloading from the site.
2) Place the script in root directory. (you can place it anywhere though)
3) Place <?php include('csource.php')?> on every page that you want to encrypt.

However you might want to keep few things in mind.

1) Search Engine spiders (including google) will not be able to read the code of encrypted pages. So it is a good thing that this script does not encrypt all the pages, but only those pages that has <?php include('csource.php')?> on the top of them.

2) You will not be able to encrypt .html or .htm pages (unless you are phrasing them as php). So you might also wanna keep this this in mind.

3) Your best bet would be. Create clients demo only under one sub like www.domain.com/demo/client1, www.domain.com/demo/client2.... etc and for all the site make a template with <?php include('csource.php')?> within the header. So you will not have to remember to put <?php include('csource.php')?> in every page.

4) Make sure that you put the appropriate path in <?php include('csource.php')?>, cuz, if you want to encrypt pages anywhere but in the root directory, <?php include('csource.php')?> will not work - you might wanna use <?php include('../csource.php')?>

Hope this helps.

NeedScripts

grahamstewart

2:43 am on Apr 19, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Alternative approaches:

  • don't publish your demos on the web. Keep them on a laptop and show clients personally.

  • put all your demos in an directory that requires a password to access. Issue this password to clients.

  • protect yourself legally by copyrighting your work.
  • shawn

    7:04 am on Apr 19, 2003 (gmt 0)

    10+ Year Member



    Thank You for your responses - I have been using demos behind HTACCESS protected pages and that seems to work out ok.

    Sticking to the laptop is a good idea also.

    Shawn