TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 05-11-2012, 12:59 PM   #1 (permalink)
The Visitor
Newcomer 
 
Join Date: May 2012
Posts: 1
Thanks: 0
anilsoni7 is on a distinguished road
Default what i done wrong here?

error

Warning: fread(): supplied argument is not a valid stream resource in C:\xampp\htdocs\Membership\login.php on line 95

Warning: fclose(): supplied argument is not a valid stream resource in C:\xampp\htdocs\Membership\login.php on line 98

Fatal error: Call to undefined function: encode_decode() in C:\xampp\htdocs\Membership\login.php on line 105


Code


<?php
/*
Login header - The following line MUST be included on TOPMOST of your website
then put the form whereever you want. This is so, because we might need to redirect
and PHP CAN NOT redirect after any output to the browser
*/

/*
The next line is to be placed on top-most of your site:
*/
//require_once('extensions/login.php');


require_once('languages/language.php');


?>
<form name="login" id="login" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>" style="display:inline;">
<table width="100%" border="1" cellspacing="0" cellpadding="5">
<tr bgcolor="#BEDEDE">
<td colspan="2"><div align="center"><font color="#999999" size="4">User Login </font></div></td>
</tr>
<?php
if($message != NULL){
?>
<tr bgcolor="#FFDDDD">
<td colspan="2"><strong><font color="#FF0000"><?php echo $message;?></font></strong></td>
</tr>
<?php } ?>
<tr>
<td>Select Membership: </td>
<td width="50%"><font size="2">
<select id="membership_id" name="membership_id" class="hiddenText">
<?php
foreach($membershipList as $em){
if($_POST['membership_id'] == $em['membership_id']){ $sel= ' selected';}else{$sel=NULL;}
echo '<option value="'.$em['membership_id'].'"'.$sel.'>'.$em['membership_title'].'</option>';
}
?>
</select>
</font></td>
</tr>
<tr>
<td width="50%">Please enter Email: </td>
<td width="50%"><input name="user_email" type="text" id="user_email" value="<?php echo $_POST['user_email'];?>">
</td>
</tr>
<tr>
<td>Please enter Password: </td>
<td width="50%"><input name="user_password" type="password" id="user_password"></td>
</tr>
<?php
if($CF_CAPTHCA == 'IMAGE'){?>
<tr>
<td>Enter Verification Code: </td>
<td><table border="0" cellspacing="0" cellpadding="5">
<tr>
<td class="acont"><div align="center">
<?php
$referenceid = md5(mktime()*rand());
//Generate the random string
$chars = array("a","A","b","B","c","C","d","D","e","E","f", "F","g","G","h","H","i","I","j","J","k",
"K","l","L","m","M","n","N","o","O","p","P","q","Q ","r","R","s","S","t","T","u","U","v",
"V","w","W","x","X","y","Y","z","Z","1","2","3","4 ","5","6","7","8","9");
$length = $CF_LENGH;
$textstr = "";
for ($i=0; $i<$length; $i++) {
$textstr .= $chars[rand(0, count($chars)-1)];
}
$new_string = encode_decode($textstr,$CF_ENCDEC);
$image_link = bin2hex($new_string);
?>
<img src="captcha.php?code=<?php echo $image_link;?>">
<input name="registration_id" type="hidden" id="registration_id" value="<?php echo $image_link;?>">
</div></td>
</tr>
<tr>
<td class="acont"><div align="center">
<input name="answer" type="text" id="answer">
</div></td>
</tr>
</table></td>
</tr>
<?php
} else {
$f = fopen($CF_QUESTIONFILE,'r');
while($t = fread($f,102465)){
$content .= $t;
}
fclose($f);
$content = trim(preg_replace('/\/\*.*\*\//ism', '', $content));

$temp = explode("\n",$content);
$random = rand(0,count($temp)-1);
$rand = $temp[$random];
list($question,$registration_id) = explode('\n\\',$rand);
$registration_id = bin2hex(encode_decode($registration_id,$CF_ENCDEC) );
?>
<tr>
<td>Answer this: <strong><?php echo $question;?></strong> </td>
<td><input name="answer" type="text" id="answer" value="<?php echo $_POST['answer'];?>">
<input name="registration_id" type="hidden" id="registration_id" value="<?php echo $registration_id;?>"></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input id="persistent" name="persistent" value="yes" checked="checked" type="checkbox">
Keep me signed in<br>
<font color="#999999" size="2">for
<select name="persistentFor" id="persistentFor" style="border:0px;color:#999999;font-size:10px;">
<?php
if($_POST['persistentFor'] == NULL){$_POST['persistentFor'] = 2;}
for($x=1;$x<=480;$x++){
if($x == $_POST['persistentFor']){$sel= ' selected';}else{$sel=NULL;}
echo '<option value="'.$x.'"'.$sel.'>'.$x.'</option>';
}
?>
</select> week unless I sign out.<br/>
[Uncheck if on a shared computer] </font>
</div></td>
</tr>
<?php } ?>
<tr bgcolor="#BEDEDE">
<td colspan="2"><div align="center">
<input type="submit" name="Submit" id="Submit" value="Login">
<input name="S_ID" type="hidden" id="S_ID" value="2">
</div></td>
</tr>
<tr bgcolor="#CAFFCA">
<td colspan="2"><div align="center">[<a href="forgotpass.php">Forgot Password </a> - <a href="register.php">Register</a>] </div></td>
</tr>
</table>
</form>
anilsoni7 is offline  
Reply With Quote
Old 05-14-2012, 01:29 PM   #2 (permalink)
The Addict
 
tony's Avatar
 
Join Date: Aug 2008
Posts: 336
Thanks: 8
tony is on a distinguished road
Default

Hi anilsoni7 welcome to the forum.

Based on the warnings it seems that the problems are in this lines:
php Code:
<?php
$f = fopen($CF_QUESTIONFILE,'r');
while($t = fread($f,102465)){
  $content .= $t;
}
fclose($f);
$content = trim(preg_replace('/\/\*.*\*\//ism', '', $content));

$temp = explode("\n",$content);
$random = rand(0,count($temp)-1);
$rand = $temp[$random];
list($question,$registration_id) = explode('\n\\',$rand);
$registration_id = bin2hex(encode_decode($registration_id,$CF_ENCDEC));

//mainly this lines; as the warnings show you the line numbers
while($t = fread($f,102465)){
fclose($f);
$registration_id = bin2hex(encode_decode($registration_id,$CF_ENCDEC));
?>
The first 2 warnings the problem seems to be that the fopen is not opening the $CF_QUESTIONFILE right so it returns FALSE. I would double check that $CF_QUESTIONFILE holds a valid path. (On I side not I find the functions file and file_get_contents easier to work with then the fopen,fread,fclose combo).

The last warning is basically saying that the encode_decode function doesn't exist. I know it doesn't exist in PHP so make sure it is implemented before it is used, either in the same file or in the require_once/require/include_once/include files.

P.S. Please use the PHP tags so that the PHP code retains the indentation when copied and is syntax highlighted. Easier to read.
tony is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Perhaps I'm doing this wrong.. Enfernikus Absolute Beginners 2 02-27-2010 05:48 PM
Anything wrong with this? shankar Absolute Beginners 2 04-17-2009 12:41 PM
What am I doing wrong here? Sam Granger General 2 04-16-2009 12:41 AM
Whats wrong with storing your salt in DB? Nor General 10 12-03-2007 03:45 PM
What's wrong? Tanax Absolute Beginners 12 09-20-2007 01:37 PM


All times are GMT. The time now is 07:59 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design