Jump to content

hitman6003

Members
  • Posts

    1,807
  • Joined

  • Last visited

Posts posted by hitman6003

  1. You can "seek" to a certain place in a file using fseek.

     

    http://www.php.net/fseek

     

    You can determine the current byte position using ftell.

     

    http://www.php.net/ftell

     

    However I think what you want is a combination of more common functions:

     

    // Read the entire file into an array, one line to an element
    $file = file("/path/to/file");
    
    // loop through the lines
    foreach ($file as $line) {
      // split each line on one or more space characters ("\t", " ", etc)
      $data[] = preg_split('/\s+/', $line);
    }
    
    echo '<pre>' . print_r($data, true) . '</pre>';

  2. the plain-text password won't be hard to bruteforce (due to rainbow tables)

     

    It's not plain text, and good luck trying to find a collision in md5. 

     

    As you stated, the real threat is sql injection.

     

    The password in the database is encrypted using PHP's md5(),

     

    md5 is not an encryption.  It's a hash algorithm.

     

    Are there any specific things to stop injection?

     

    Use input verification (i.e. make sure a text input only contians text) and use mysql_real_escape_string or PDO and prepared statements.

  3. if (!function_exists('file_put_contents')) {
    function file_put_contents($file, $contents)  {
    	$fh = fopen($file, 'w') or die("can't open file");
    
    	if(!$fh) {
    		trigger_error('file_put_contents cannot write in file.', E_USER_ERROR);
    		return;
    	}
    
    	fwrite($fh, $contents);
    	fclose($fh);
    }
    }

     

    didn't notice that the function declaration was wrong...

  4. Try cleaning up your html...there is unclosed tags everywhere and other mistakes that can interfere. 

     

    Why is there a semi-colon in the form declaration? 

    <form method="post" action="http://www.glflamason.org/NEWSITE/NEW2/lodgelocator/3results.php"; target="_blank">

     

    There is a span in the middle of a paragraph tag:

    <p align="center"<span class="style9">Enter District Number:</span> 

     

    Your html doesn't necessarily need to validate, but if you're having problems, it usually a good step to go back, clean up, and make sure that all your tags match up.

  5. You have to define the function before you use it:

     

    <?php
    if (!function_exists('file_put_contents')) {
    function file_put_contents($file, htmlspecialchars(stripslashes($_POST['message'])))  {
    	$fh = fopen($file, 'w') or die("can't open file");
    
    	if(!$fh) {
    		trigger_error('file_put_contents cannot write in file.', E_USER_ERROR);
    		return;
    	}
    
    	fputs($fh, $file);
    	fclose($fh);
    }
    }
    
    if (file_put_contents($file, htmlspecialchars(stripslashes($_POST['message'])))) {		
    echo "Your message was recorded";
    } else {
    echo "An error occurred";
    }
    ?>

  6. Code, by it's nature, is pretty self explanatory.  Barand didn't do anything exotic.  Well, maybe a multidimensional array...but that's not exotic.

     

    Everything is done for you except the part where you actually process the data, and Barand even told you where to put that.

     

    In addition to that, Barand went back and rewrote part of his code to take into account the multiple file uploads:

     

    http://www.phpfreaks.com/forums/index.php/topic,192347.msg865206.html#msg865206

     

    So, what explanation do you want?

  7. Simply copy their form values...same action value in the form declaration, same field names and data types, then you should be good.  Your form will simply submit into the existing login process.

  8. Congratulations, your code made my head hurt so bad, I was forced to rewrite it...

     

    <?php
    if ($_POST['message'] != "") {
    switch ($_POST['name']) {
    	case 'Jamil':
    		$file = 'jamil.txt';
    		break;
    	case 'Razy':
    		$file = 'razy.txt';
    		break;
    	case 'Stephanie':
    		$file = 'stephanie.txt';
    		break;
    }
    
    /*
    	Alternate filename, which would eliminate the switch above:
    	$file = $_POST['name'] . ".txt";
    */
    
    if (file_put_contents($file, htmlspecialchars(stripslashes($_POST['message']))) {
    	echo "Your message was recorded";
    } else {
    	echo "An error occurred";
    }
    }
    ?>
    
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method='post'>
    <p class="style2">
    <select name="name">
    	<option>Jamil</option>
    	<option>Razy</option>
    	<option>Stephanie</option>
    </select>
     
    Message Updater:
    </p>
    <p class="style2">
    <input type="text" name="message" />
    </p>
    <p class="style2">
    <input type="submit" Value="Build"/>
    </p>
    </form>
    

  9. What doesn't work about it?  Is there an error generated?  If so, what is it?  Have you tried troubleshooting?  What have you done to troubleshoot?  Have you verified the value of $_POST['id']?  Why are you duplicating all of the code in two places?  Employ the DRY method (http://en.wikipedia.org/wiki/DRY) to simplify.

     

    if($_POST['id'] == "NN") {
    $to='your@email.com';
    } else if($_POST['id'] == "NI") {
    $to='me@email.com';
    }
    
    echo "This message will be sent to " . $to . " because id is equal to " . $_POST['id'];
    
    $subject = $_POST[subject]; 
    $headers = "From: Autisim Summer Camp Information\r\nX-Mailer: Autisim Summer Camp"; 
    $body = "$_POST[first] $_POST[last] from $_POST[email] is requesting information about $_POST[subject].
    In addition, they have posted this message: 
    $_POST[message]"; 
    mail($to, $subject, $body, $headers); 

  10. yes.

     

    Now, please be more specific.  What forum are you using?  phpBB? SMF? ...?  Are you wanting to create a different login form for the forum, or are you using the user database from the forum for auth to a different app?

  11. Have you checked permissions on the directory you are trying to write to?

     

    Seeing as how you can write to the current directory, I'd say that the file functions are broken.  Most likely the Apache user doesn't have permission to write to the directory you are providing.

×
×
  • 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.