Jump to content

Freecap woes =(


ggkfc

Recommended Posts

Hello

ive tried to use freecap inside my own index.php but its seemed to failed to work. basically i have a form up that loads a users id, name and score. for each time he answers the captcha right, score will increase by one. unfortunately, when i use the freecap_wrap.php it works perfectly fine, displaying whether you typed the right or wrong captcha when you submit. when i copied it into my pre-existing index.php, the refresh function works but the right/wrong thing never turns up (the subsequent increase in score). being a php noob, would any expert mind taking a look at what i have messed up?

 

<?
require_once 'dbappinclude.php';
if(!empty($_SESSION['freecap_word_hash']) && !empty($_POST['word']))
{
// all freeCap words are lowercase.
// font #4 looks uppercase, but trust me, it's not...
if($_SESSION['hash_func'](strtolower($_POST['word']))==$_SESSION['freecap_word_hash'])
{
	// reset freeCap session vars
	// cannot stress enough how important it is to do this
	// defeats re-use of known image with spoofed session id
	$_SESSION['freecap_attempts'] = 0;
	$_SESSION['freecap_word_hash'] = false;


	// now process form
if($word_ok!==false)
{
if($word_ok=="yes")
{
	echo "you got the word correct, rock on.<br />";		
} else {
	echo "sorry, that's not the right word, try again.<br />";
}
}


	// now go somewhere else
	// header("Location: somewhere.php");
	$word_ok = "yes";
} else {
	$word_ok = "no";
}
} else {
$word_ok = false;
}

$rs = query("select ID from users where ID = $user");

if ($row = mysql_fetch_assoc($rs)) {
  echo "<p>hello $user</p>";
} else {
  query("INSERT INTO users (ID) VALUES ($user)");
  echo "<p>you have been registered $user</p>";
}
$rs = query("select * from users where ID = $user");
if ($row = mysql_fetch_assoc($rs)) {
  $cash = $row['Cash'];
  $name = $row['Name'];
  $bank = $row['Bank'];
  $token = $row['Token'];
} else {
  query("insert into users values (1)");
  $cash = 1;
}
echo "<p>Name: $name</p>";
echo "<p>Cash: $cash</p>";
echo "<p>Bank: $bank</p>";
echo "<p>Token: $token</p>";

?>

<script language="javascript">
<!--
function new_freecap()
{
// loads new freeCap image
if(document.getElementById)
{
	// extract image name from image source (i.e. cut off ?randomness)
	thesrc = document.getElementById("freecap").src;
	thesrc = thesrc.substring(0,thesrc.lastIndexOf(".")+4);
	// add ?(random) to prevent browser/isp caching
	document.getElementById("freecap").src = thesrc+"?"+Math.round(Math.random()*100000);
} else {
	alert("Sorry, cannot autoreload freeCap image\nSubmit the form and a new freeCap will be loaded");
}
}
//-->
</script>


<form action="<?=$_SERVER['PHP_SELF']?>" method="post">
<table cellpadding="0" cellspacing="0">
<tr><td colspan="2"><img src="freecap.php" id="freecap"></td></tr>
<tr><td colspan="2">If you can't read the word, <a href="#" onClick="this.blur();new_freecap();return false;">click here</a></td></tr>
<tr><td>word above:</td><td><input type="text" name="word"></td></tr>
<tr><td colspan="2"><input type="submit" value="submit"></td></tr>
</table><br /><br />
</form>

Link to comment
https://forums.phpfreaks.com/topic/78046-freecap-woes/
Share on other sites

yes i ahve added it now @ the begginning xD

 

but now i get

Access forbidden!

You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.

If you think this is a server error, please contact the webmaster.
Error 403
127.0.0.1
11/24/07 18:30:46
Apache/2.2.6 (Win32) DAV/2 mod_ssl/2.2.6 OpenSSL/0.9.8e mod_autoindex_color PHP/5.2.4 

Link to comment
https://forums.phpfreaks.com/topic/78046-freecap-woes/#findComment-397994
Share on other sites

<?
require_once 'dbappinclude.php';
$rs = query("select ID from users where ID = $user");

if ($row = mysql_fetch_assoc($rs)) {
  echo "<p>hello $user</p>";
} else {
  query("INSERT INTO users (ID) VALUES ($user)");
  echo "<p>you have been registered $user</p>";
}
$rs = query("select * from users where ID = $user");
if ($row = mysql_fetch_assoc($rs)) {
  $cash = $row['Cash'];
  $name = $row['Name'];
  $bank = $row['Bank'];
  $token = $row['Token'];
} else {
  query("insert into users values (1)");
  $cash = 1;
}
echo "<p>Name: $name</p>";
echo "<p>Cash: $cash</p>";
echo "<p>Bank: $bank</p>";
echo "<p>Token: $token</p>";
require_once 'freecap_wrap.php';
?>
[code]

basically now i have it running index.php running the freecap_wrap inside
the only problem is "Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\tut\index.php:6) in C:\xampp\htdocs\tut\freecap_wrap.php on line 2"

as in a header/session clash or something because both freecap & freecap_wrap.php use a session start right?
or is there something i am missing. thnx in advance

[/code]

Link to comment
https://forums.phpfreaks.com/topic/78046-freecap-woes/#findComment-398000
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.