PDA

View Full Version : PHP Disguise



MrCraig
12-12-2007, 05:30 PM
Okay, Ive made this script for people who use proxies in school and dont want the school to know what the site is all about.

It was inspired by Dentafrice, who originally used it for his proxy, so ive decided to make my own version of it.

Basically, The use must refresh the page 4 times to get onto the actual proxy. If the user has not refreshed the page, it will show up a message of your choice.

Code:


<?php
ob_start();

/*
CONFIG
*/

$message = "Sorry, This website is not currently open!"; #Message to show to users who havent refreshed.

/*
DONT EDIT BELOW
*/

if($_COOKIE["refresh"]!=3)
{
if(isset($_COOKIE["refresh"]))
{
$ref_value = $_COOKE["refresh"] + 1;
setcookie("refresh",$ref_value,time()+3600);
die("$message");
}
else
{
setcookie("refresh","1",time()+3600);
die("$message");
}
}
?>


Its just a simple script and simply include it in every page you wish to protect in this way.

Hope you enjoy :)

Havent tested for errors yet, so if anybody finds any, just tell me :)

Moved by Agesilaus (Forum Moderator) from Design and Development: Please post in the correct forum next time. :)

Luno1599
12-12-2007, 05:44 PM
Nice i can use this!,
Dose anyone know of a very very good free proxy?
Dan

[EDIT: It dosent work http://www.masterhostuk.com/v7/testttt.php (http://www.masterhostuk.com/v7/testttt.php) sould come up with hello]

Invent
12-12-2007, 05:48 PM
*Originally by Danny/Luckyrare
*Already been posted many times
*Your code is wrong

Luno1599
12-12-2007, 05:58 PM
Have u got a link for the other post?
Dan

MrCraig
12-12-2007, 07:24 PM
*Originally by Danny/Luckyrare
*Already been posted many times
*Your code is wrong


* Sorry, i thought it was Denta's for some reason..
* Ive never seen it posted before
* Please post a suggestion on how to fix?

EDIT:



<?php
ob_start();

/*
CONFIG
*/

$message = "Sorry, This website is not currently open!"; #Message to show to users who havent refreshed.

/*
DONT EDIT BELOW
*/

if($_COOKIE["refresh"]!=3)
{
if(isset($_COOKIE["refresh"]))
{
$ref_value = $_COOKIE["refresh"] + 1;
setcookie("refresh",$ref_value,time()+3600);
die("$message");
}
else
{
setcookie("refresh","1",time()+3600);
die("$message");
}
}
?>


Sorry, Missed out an "I" in cookie.

Luno1599
12-12-2007, 07:27 PM
http://www.habboxforum.com/showthread.php?t=403822
This is the other post

Chippiewill
12-12-2007, 08:17 PM
Ive seen this loads before, and there are far better ones anyway

Dentafrice,
12-12-2007, 08:24 PM
Correction (Danny/Luckyrare) was the one to use this :P I never had a proxy although I did write a small script in Danny's post that seemed a little easier to use :)

MrCraig
12-12-2007, 08:28 PM
I know lol :)

For some reason i always get mixed up between you and danny :P

And its not really that hard to use, All you have to do is edit the message variable to what you want to display it, then include the script :P

Thanks for your comments anyways =]

Beau
13-12-2007, 10:16 AM
Nice idea actually, never would have thought of it myself. I'd be using sessions as oppose to cookies however, although that really is just an individual preference I guess.

Florx
13-12-2007, 04:33 PM
Sessions are easier to handle and will only last until the user closes the browser = Instant logout / session deletion, however a mixture is good :)

MrCraig
13-12-2007, 05:33 PM
Nice idea actually, never would have thought of it myself. I'd be using sessions as oppose to cookies however, although that really is just an individual preference I guess.

Was Danny's idea orig :)

And i might make a new version but the admin chooses whether to use sessions or cookies?

Beau
14-12-2007, 04:56 AM
Was Danny's idea orig :)

And i might make a new version but the admin chooses whether to use sessions or cookies?

Nah, no point IMO. Only admin feature required would be to change the amount of times one needs to refresh the page.

Mentor
14-12-2007, 05:45 AM
Just as a quick rewrite, it would probably be more secure to use sessions for something like this, plus the code can be optimised quite easily.

For example, this (if java hasn't completely overridden my php ability) should do pretty much the same with less bloat & better readabilty.



<?php
session_start(); // start sessions

//Change these
$noDisplayMessage =" no site ere ";
$timesNeeded = 3; //how many refreshes are needed to view page
//Don't Change
if($_SESSION['views']<$timesNeeded) //PHP will initialise at zero.
{
$_SESSION['views']++; //increment sessions counter
die($noDisplayMessage); //die and show message
}
?>


-include at top of pages

A possible further optimisation would be to put the code in another file, then u can just include it when ever you need it. Only issue is with sessions as it may conflict if its initialised a second time in the main code... a simple edit would fix that though.

Zaub
14-12-2007, 06:42 AM
Omg awesome script. Good work.

lolwut
14-12-2007, 10:54 PM
This is the one I use to hide sites from teachers at school, own code:


<?php

ob_start();

$no = "Nothing here.";
$yes = "You're well smart.";

if(!$_COOKIE['views']){
setcookie("views","1");
die($no);
}elseif($_COOKIE['views'] == "1"){
setcookie("views","2");
die($no);
}elseif($_COOKIE['views'] == "2"){
setcookie("views","3");
die($no);
}elseif($_COOKIE['views'] == "3"){
die($yes);
}

?>

Mentor
15-12-2007, 01:03 PM
This is the one I use to hide sites from teachers at school, own code:


<?php

ob_start();

$no = "Nothing here.";
$yes = "You're well smart.";

if(!$_COOKIE['views']){
setcookie("views","1");
die($no);
}elseif($_COOKIE['views'] == "1"){
setcookie("views","2");
die($no);
}elseif($_COOKIE['views'] == "2"){
setcookie("views","3");
die($no);
}elseif($_COOKIE['views'] == "3"){
die($yes);
}

?>



Again, lots of wasted code, you only need one check, not 4 :rolleyes:

(or 2 if you want the pre final code message to appear o.0)

The greater than / less than comparisons <> are there for a reason.

DeejayMachoo$
15-12-2007, 01:15 PM
Again, lots of wasted code, you only need one check, not 4 :rolleyes:

(or 2 if you want the pre final code message to appear o.0)

The greater than / less than comparisons <> are there for a reason.

<?php

ob_start();

$no = "Nothing here.";
$yes = "You're well smart.";

if($_COOKIE['views'] == "3"){
echo("$yes");
}else{
setcookie("views", ++);
die($no);
}

?>

Mentor
15-12-2007, 06:12 PM
<?php

ob_start();

$no = "Nothing here.";
$yes = "You're well smart.";

if($_COOKIE['views'] == "3"){
echo("$yes");
}else{
setcookie("views", ++);
die($no);
}

?>
A few logical + syntactical errors there.
++ requires a variable to add to.
Secondly, if we assume the cookie set was actually storeing an incriment counted, it would only ever display yes and the final page on the 3rd viewing, then never again after that till the cookie was deleited or expired? Which could be a pain in the ****

Dentafrice,
15-12-2007, 06:13 PM
Again, why the hell are you using cookies.
Sessions are better, plus they are there for the browser session, cookies are there.. until.. a while.

Mentor
15-12-2007, 06:19 PM
Again, why the hell are you using cookies.
Sessions are better, plus they are there for the browser session, cookies are there.. until.. a while.

I did actually post a session using version of the script as an example, a few posts up :p

Dentafrice,
15-12-2007, 06:21 PM
Sorry, wasn't aimed at you :P I saw it the other day.

I just seem him contining to post using cookies :P

Beau
15-12-2007, 08:19 PM
Sessions > Cookies. Nuff said :P

Florx
15-12-2007, 08:24 PM
Sessions > Cookies. Nuff said :P
and well said.

Mentor
15-12-2007, 08:26 PM
Sessions > Cookies. Nuff said :P
Not really, it kinda depends on what your trying to do, remembering a users login details for instance is a task cookies easily > sessions for instance.

Both are better at different things, the skill is to use the right one for the right purposes :)

--ss--
15-12-2007, 08:40 PM
Just as a quick rewrite, it would probably be more secure to use sessions for something like this, plus the code can be optimised quite easily.

For example, this (if java hasn't completely overridden my php ability) should do pretty much the same with less bloat & better readabilty.



<?php
session_start(); // start sessions

//Change these
$noDisplayMessage =" no site ere ";
$timesNeeded = 3; //how many refreshes are needed to view page
//Don't Change
if($_SESSION['views']<$timesNeeded) //PHP will initialise at zero.
{
$_SESSION['views']++; //increment sessions counter
die($noDisplayMessage); //die and show message
}
?>

-include at top of pages

A possible further optimisation would be to put the code in another file, then u can just include it when ever you need it. Only issue is with sessions as it may conflict if its initialised a second time in the main code... a simple edit would fix that though.
Is there a way of having it like danny had a 'panic button' where if you clicked/ refreshed the page it will show the not available message , and if you refreshed again it will show the site contents?
I'm guessing it can be done by having it so on the 3rd refresh it changes it back to 1 refresh and it keeps going in a loop?

Mentor
15-12-2007, 08:57 PM
Is there a way of having it like danny had a 'panic button' where if you clicked/ refreshed the page it will show the not available message , and if you refreshed again it will show the site contents?
I'm guessing it can be done by having it so on the 3rd refresh it changes it back to 1 refresh and it keeps going in a loop?
or have a special condition added.
Say on the page theres a link called panic.
The link points to whateverpagethisison.php?a=panic

Now with this code that would reset the refresh counters and load the first page



<?php
session_start(); // start sessions

//Change these
$noDisplayMessage =" no site ere ";
$timesNeeded = 3; //how many refreshes are needed to view page

//Don't Change
if($GET_['a']=="panic") // if panic button hit
{
$_SESSION['views'] = -1; // set views counter to zero
header("Location: ".$_SERVER['PHP_SELF']) ; // reload page
}
elseif($_SESSION['views']<$timesNeeded) //PHP will initialise at zero.
{
$_SESSION['views']++; //increment sessions counter
die($noDisplayMessage); //die and show message
}
?>

(bin doin Java to long, cant remember if phps else if is joint or not. if im wrong add a space in there 2 fix)

Blob
15-12-2007, 09:37 PM
or have a special condition added.
Say on the page theres a link called panic.
The link points to whateverpagethisison.php?a=panic

Now with this code that would reset the refresh counters and load the first page



<?php
session_start(); // start sessions

//Change these
$noDisplayMessage =" no site ere ";
$timesNeeded = 3; //how many refreshes are needed to view page

//Don't Change
if($GET_['a']=="panic") // if panic button hit
{
$_SESSION['views'] = -1; // set views counter to zero
header("Location: ".$_SERVER['PHP_SELF']) ; // reload page
}
elseif($_SESSION['views']<$timesNeeded) //PHP will initialise at zero.
{
$_SESSION['views']++; //increment sessions counter
die($noDisplayMessage); //die and show message
}
?>

(bin doin Java to long, cant remember if phps else if is joint or not. if im wrong add a space in there 2 fix)

Its joint.

Want to hide these adverts? Register an account for free!