Jump to content

alpine

Members
  • Posts

    759
  • Joined

  • Last visited

Posts posted by alpine

  1. Case closed !
    You are obviously in lack of basic understanding about how a forum like this works. We are not here to tell you that you need to post the current code when you need help, and we are definetively not here to tell you what exactly that means. A thread like this will without doubt go on for pages and my "be patient scale" just exceeded.
  2. A lot of those bulk issues can be avoided by providing som proper headers in the message.
    A lot of questions is regarding this exact problem, so i'll provide an example of a setup that should improve this - study it:
    [code]

    <?php

    // $your_sitename = "here";
    // $your_sitemail = "mail@here.net";

    // $recipient = $_POST['recipient']; // or a static one ofcourse
    // $subject = $_POST['message']; // or a static one
    // $message = $_POST['message'];

    $naughty = "/(%0A|%0D|\\n+|\\r+)(content-type:|mime-version:|cc:|bcc:)/i";
    if(preg_match($naughty, $subject) || preg_match($naughty, $recipient))
    {
      die("Sorry, injection attempt blocked!");
    }
    if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $recipient))
    {
      die("Not a valid email adress was provided");
    }

    $eol = "\r\n";
    $headers = "From: $your_sitename <$your_sitemail>".$eol;
    $headers .= "Reply-To: $your_sitename <$your_sitemail>".$eol;
    $headers .= "Return-Path: $your_sitename <$your_sitemail>".$eol;
    $headers .= "X-Mailer: PHP v".phpversion().$eol;
    $headers .= "Date: ".date("r").$eol;
    $headers .= "Message-ID: <".date("YmdHis").substr(md5(rand()),12)."@".$_SERVER['SERVER_NAME'].">".$eol;
    $mime_boundary = md5(time());
    $headers .= 'MIME-Version: 1.0'.$eol;
    $headers .= "Content-Transfer-Encoding: 8bit".$eol;
    $headers .= "Content-Type: multipart/related; boundary=\"".$mime_boundary."\"".$eol;
    $msg = "";
    $msg .= "--".$mime_boundary.$eol;
    $msg .= "Content-Transfer-Encoding: 8bit".$eol;
    $msg .= "Content-Type: text/plain; charset=iso-8859-1".$eol; // <-- modify charset to suit

    $msg .= $eol.$eol.$message.$eol.$eol;

    $msg = wordwrap($msg, 70);

    if(ini_get('safe_mode'))
    {
    mail($recipient, $subject, $msg, $headers);
    }
    else
    {
    mail($recipient, $subject, $msg, $headers, "-f" . $your_sitemail);
    }

    ?>

    [/code]
  3. It was discussed wether to kill the short tags from php6, it seems however that it's desided to allow <? for now. But who knows in future releases, i would stick to <?php

    http://php6dev.blogspot.com/#remove-support-for-and-script-language-php-and-add-php-var
  4. You could set a cookie that lasts for a year at a time, so unless the user cleans up his cookies (deletes them) it will be an autologin feature for a year at a time.

    Example to set a cookie after login success:
    [code]

    <?php

    if($login_ok) // simplified example
    {
    // set a cookie that will work for 365 days (one year)
    setcookie("user", "Donald Duck", time()+60*60*24*365,"/",".Duckburg_yourdomain.com",0);
    }

    ?>

    [/code]

    And on your main page, check if this cookie already exists - something like this:
    [code]

    <?php

    if(isset($_COOKIE['user']) && !empty($_COOKIE['user']))
    {
      // your cookie is found
      $user = htmlspecialchars($_COOKIE['user'], ENT_QUOTES);
     
      print "Hello {$user}, Welcome back!";
     
      // or redirect
      header("Location: members.php");
      exit();
    }
    else
    {
      // no cookie found matching your check
      print "Hello guest, If you already have an account, please log in first";
    }

    ?>

    [/code]

    For understanding cookies, use the manual: http://no2.php.net/manual/en/function.setcookie.php
  5. replace
    [code]
    $check = mysql_query("SELECT * FROM users WHERE pass = '$pass' AND id = '$id'");
    [/code]

    with
    [code]
    $check = mysql_query("SELECT * FROM users WHERE pass = '$pass' AND id = '$id'") or die(mysql_error());
    [/code]

    and see what the mysql error is
  6. [quote author=Mutley link=topic=121052.msg497868#msg497868 date=1168048065]
    I like yours Alpine but if my cookie is encrypted, does it read it normally or do I need some PHP to decode it?
    [/quote]

    You don't decrypt the cookie value, you simply compare encrypted value (like the cookie value) with another encrypted value (like the encrypted db-value) to see if they match. If they match, the values before encryption is in most cases identical. This is if the encryption methods are the same on both values ofcourse (md5() etc)
  7. [quote author=psychohagis link=topic=121052.msg497564#msg497564 date=1168023521]
    why are you using cookies? sessions are more secure?
    [/quote]

    was that supposed to be a question or a statement ? ...It really doesn't matter much if you do not validate user input from injecting your query, yours is wide open!
  8. Look at this, an example using cookies
    [code]

    <?php

    if(!empty($_COOKIE['user']) && !empty($_COOKIE['pass']))
    {
      $user = htmlspecialchars($_COOKIE['user'], ENT_QUOTES);
      $pass = htmlspecialchars($_COOKIE['pass'], ENT_QUOTES);
     
      $check = mysql_query("SELECT * FROM users WHERE pass = '$pass' AND user = '$user'");
     
      if(mysql_num_rows($check) <> 1)
      {
        echo "No accsess granted with your current userdata";
        exit();
      }
      else
      {
        echo "Logged in as $user";
      }
    }
    else
    {
      echo "You have to be logged in to visit this section";
      exit();
    }

    ?>

    [/code]
  9. Regarding margin etc: I've actually done over one of my sites to fully CSS myself the last couple of days - and i have to admit that when getting <sort of> the hang of it, it's cool to work with (i never thought i should <ever> say that).
    I have one friend running ONLY Linux, i get him to screenshot me various browsers whenever i need - and i have another friend (i actually have a few friends when i start thinking.!.) that is running ONLY Mac, i also get a few screenshots there when i ask. A screenshot tells definitively more than one can ever explain.

    * And EDIT: Only IE7 states error, not IE6
×
×
  • 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.