Announcement

Collapse
No announcement yet.

This is driving me NUTS

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • This is driving me NUTS

    PHP Code:

    <?php

         
             validate
    ($user);
             
             function 
    validate ($username) {
                      
    $username strtolower($username);
                                 
    $pointer fopen("http://www.epinions.com/user-$username""r");
                                if (
    $pointer) {
                                     
    $buffer "";
                                     while (!
    feof($pointer)) {
                                                  
    $buffer.=fread($pointer,4096);
                                     }
                                    
    fclose($pointer);
                                
                                  if (
    stristr ($buffer,"About $username"))
                    {
                                     
    $status true;
                                  }        
                                  else 
    $status false;
                                }
                                
                                else 
    $status $false;
                                
                                echo 
    $status;                
             }
    ?>
    The script works great if the user exists. However, if the user does NOT exist, Epinions returns an error page. Then, all I get is

    Warning: fopen("http://www.epinions.com/user-ju8","r") - Success in /home/epinionf/public_html/validate.php on line 8
    I never get $status set to false. What am I doing wrong?

    Amy
    http://www.eaforums.com

  • #2
    Why don't you use the file_exists() function:
    http://www.php.net/manual/en/function.file-exists.php

    I think it's exactly what you need for this purpose.
    Chen Avinadav
    Better to remain silent and be thought a fool than to speak out and remove all doubt.

    גם אני מאוכזב מסיקור תחרות לתור מוטור של NRG הרשת ע"י מעריב

    Comment


    • #3
      file_exists is returning false, even if the username exists.


      I DID fix it though

      I changed $status = false to $status = "0"

      and I changed

      $pointer = fopen("http://www.epinions.com/user-$username", "r");

      to

      $pointer = @ fopen("http://www.epinions.com/user-$username", "r");


      Now, I am getting the answer I need.

      Thanks for the suggestion though. I learned a new php function today.

      Amy
      http://www.eaforums.com

      Comment


      • #4
        Originally posted by amykhar
        file_exists is returning false, even if the username exists.
        I wonder why.

        Anyway, glad you got it working.
        Chen Avinadav
        Better to remain silent and be thought a fool than to speak out and remove all doubt.

        גם אני מאוכזב מסיקור תחרות לתור מוטור של NRG הרשת ע"י מעריב

        Comment


        • #5
          This script is going to save me SO much time. I have two types of users:

          1. Epinions members
          2. Normal people

          Before, Epinions members had to email me for access to the Epinions forums. Now, when they activate their account, it automatically checks to see if they belong to Epinions. If they do, it moves them to the Epinions usergroup. If they don't it moves them to the registered usergroup.

          This is great, because the Epinions people NEVER read the instructions that said they needed to email me for access.

          I love it

          Amy
          http://www.eaforums.com

          Comment

          widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
          Working...
          X