Jump to content

ionicle

Members
  • Posts

    46
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

ionicle's Achievements

Member

Member (2/5)

0

Reputation

  1. Here's what I came up with ( it's incomplete, but it's almost there ): The DB file actually does contain a Unix timestamp right now, and it's smaller than the current one. For some reason though, all I'm getting is a blank page. Why is that? I am not quite sure of the timestampState function - what I am basically doing there, is checking if the $recorded_time variable is an integer. <? $current_time = time(); $recorded_time = recordedTime(); $time_difference = $current_time - $recorded_time; $timestamp_state = timestampState($recorded_time); $threshold = "7200"; function recordedTime() { $db_file = 'db_file.txt'; $handle_check = fopen($db_file, "r"); $contents_check = fread($handle_check, filesize($db_file)); fclose($handle_check); return $contents_check; } function timestampState($recorded_time) { if($recorded_time === (int)$recorded_time) { return true; } else return false; } if ($timestamp_state == 'true') { if ($time_difference > $threshold) { echo "Time to erase this value and reset things."; } else { echo "Time to ban everyone."; die(); } } ?>
  2. Figured my plan of action would be the following: 0. declare $current_time and $recorded_time 1. open db file 2. read value in first line of db file 3. determine whether the value is a valid time value 4. if not, continue with the rest of the script 5. if yes, do the following: 5a. calculate difference between $current_time and $recorded_time 5b. if difference is larger than 2 hours, erase contents of db file and continue with the script 5c. if difference is smaller than 2 hours, echo out "404" and die() 6. check whether visitor's IP belongs to the predefined range. if it does, do the following: 6a. erase contents of db file 6b. create a new entry for $recorded_time 6c. echo out "404" and die() How do I go about step 3, specifically? Anyone?
  3. I'm not sure if I got that correctly, but let me clarify this: When a specific IP visits the page, it should start showing that predefined echo value for EVERYONE in the next 2 hours. Not just for the person from that specific IP address. And I am not using a database right now - how do I implement that? Can't I just use a plain .txt file to record the time when that IP visits the page, and just use that value to determine how long it's got left until 2 hours have expired, using time()? And when the 2 hours have expired, auto-erase the entry from the .txt file and start over?
  4. Hey guys and gals! I am currently working on implementing the following functionality in one of my pages: Whenever a person with a specific IP address visits the page, an internal countdown timer of 2 hours should be started. Until that timer is active, the only response from the page ANYONE can get would be a predefined echo value. Once the timer has run out, the normal script execution of the rest of the page should be restored. Any pointers and tips on how to approach that would be greatly appreciated.
  5. This isn't exactly a PHP issue I'm having, but it is indeed related to cURL in a way, so here it goes: How can I convert a cURL/Netscape style cookie into a valid Opera/IE cookie for usage with one of those browsers? Is that even doable?
  6. Turns out JIXO's code works. For some reason though, when I load up a large number of email addies in the arrays, it screws up and spits out a blank result. No clue why. I got another reply on Stackoverflow: <?php function domain($email){ $x=explode('@',$email); return $x[1]; } $list1=array("brym@yahoo.com","gargamel@yahoo.com","grungel@gmail.com","shushlek@hotmail.com","gushterlqk@aol.com","shuslica@web.de");//first list $list2=array("brym@yahoo.com","grungel@gmail.com");//second list $black_domains=array(); foreach($list2 as $l2){ $black_domains[]=domain($l2); } $new_list1=array(); foreach($list1 as $l1){ $domain=domain($l1); if(!in_array($domain,$black_domains)){ $new_list1[]=$l1; }; } print_r($new_list1); //this gives new list ?> That one works like a charm, even with very large lists.
  7. That looks pretty convenient! Thing is, I not only need the entire List 2 to be removed from List 1, but also have all email addresses from List 1, matching with all domain names from List 2, be removed from List 1. array_diff() wouldn't help with that, I guess.
  8. Hey again, everybody. Need help with the solution of yet another task related to php. I have two lists of email addresses - List 1 and List 2, so to say. The entire contents of List 2 is a part of List 1. I would like for PHP to compare both lists and erase all the email addresses out of List 2, that are contained in List 1, plus all the email addresses, located at every domain name, listed within List 2. For instance: List 1: brym@yahoo.com gargamel@yahoo.com grungel@gmail.com shushlek@hotmail.com gushterlqk@aol.com shuslica@web.de List 2: brym@yahoo.com grungel@gmail.com After processing's completed, List 1 should look like this: List 1: shushlek@hotmail.com gushterlqk@aol.com shuslica@web.de How would I go about doing that?
  9. Thank you everyone for the help! Issue was sorted out and everything's working like a charm now.
  10. Last suggestion works perfectly! The only thing I need now is to load a text file into the array, and avoid having to input email addresses manually. <?php // Open the file $filename = "test.txt"; $fp = @fopen($filename, 'r'); // Add each line to an array if ($fp) { $array = explode("\n", fread($fp, filesize($filename))); } //INITIALIZE ARRAYS $emails = $array; $newEmails = array(); $usedDomains = array(); $uniqueDomains = array(); //WHILE THERE ARE EMAILS AVAILABLE, PROCESS THE NEXT RANDOM ENTRY while(!empty($emails)) { //GET RANDOM EMAIL $randomEntryID = array_rand($emails); $randomEntry = $emails[$randomEntryID]; $currentDomain = substr(strrchr($randomEntry, '@'), 1); //UPDATE ARRAYS $newEmails[] = $randomEntry; $usedDomains[] = $currentDomain; unset($emails[$randomEntryID]); } //REMOVE DUPLICATE DOMAINS (ALSO GIVES THE INDEX WHERE THE DOMAIN WAS FIRST USED) $uniqueDomains = array_unique($usedDomains); $uniqueIDs = array_keys($uniqueDomains); //DISPLAY EMAILS OF INTEREST foreach($uniqueIDs as $currID) { print '<div>' . $newEmails[$currID] . '</div>'; } ?> The .txt file contains the following test emails: laina@yahoo.com kochina@yahoo.com brym@gmail.com shushlek@gmail.com kurnica@gmail.com shushlica@yahoo.com However, when I execute the php, I get the following output: kochina@yahoo.com kurnica@gmail.com shushlica@yahoo.com There's only 2 types of domains in those email addresses, and I always get 1 of one domain and 2 of the other, instead of one of each. What am I missing here?
  11. Hey everybody. Trying to figure out how to complete a certain task here, and I am pretty sure it can be done via php. Not sure how to start implementing it though, so any suggestions would be hugely appreciated. What I wanna accomplish is, as follows: Out of a list of email addresses, I would like php to pick ONE RANDOM email address out of every domain name, listed in there, for instance: dave@yahoo.com john@yahoo.com michael@hotmail.com jason@hotmail.com etc. Just one random email addy with a certain domain name ( namely, the part after the @ sign ). The ending result out of the example, listed above, ought to be: dave@yahoo.com jason@hotmail.com That's it, pretty much. Nothing more, nothing less. Open to suggestions on how to start this thing!
  12. By attempting to log in to your Yahoo account from a browser that you've never used before to do so, while having the Secondary Sign-in protection in place. Yahoo seems to set a cookie the first time you sign in to your Yahoo account from a specific browser, and it's a permanent one, even if you're logged out. It doesn't maintain a session, but if it isn't there, Yahoo will request additional verification every time you try to sign in. Using IMAP doesn't bypass the protection - that is when you get the "Notice: Unknown: [AUTHORIZATIONFAILED] Please verify your account at https://login.yahoo.com." message. Both when used in the context of a php script, and by using a regular mail client.
  13. There are 2 separate types of notices - one for Unknown user/pass, and another for Unknown location. I just want to differentiate between them and set up two unique redirects to two different pages, depending on which one of the notices is encountered. What's so complicated about that? I did it by dumping the contents of the "imap_errors" array into a file, then opening and reading it, checking for a certain string, and then doing a redirect based on that ( well, it's an echo in the example above, I will add the header redirect a bit later ). Wouldn't that work? Now the only thing I need is figure out how to configure "fopen" to overwrite the file with the new data every time it's executed, instead of just adding to it.
  14. I changed my code: <?php /* Yahoo connection params */ $hostname = '{imap.mail.yahoo.com:993/imap/ssl}INBOX'; $username = 'user@yahoo.com'; $password = 'password'; /* Initialize connection */ $inbox = @imap_open($hostname,$username,$password); $filename = "imap.txt"; $errors = imap_errors(); for ($i=0; $i<count($errors); $i++) { $file = fopen("$filename", "a"); fputs($file, "$errors[$i]\r\n"); fclose($file); $response = file_get_contents('$filename'); if ($response == '[AUTHORIZATIONFAILED] Incorrect username or password. (#MBR1212) [AUTHORIZATIONFAILED] Incorrect username or password. (#MBR1212) [AUTHORIZATIONFAILED] Incorrect username or password. (#MBR1212) Too many login failures') { echo 'Done.'; } } ?> How do I make sure that, whatever's in "imap.txt", gets overwritten every time the script is run, and not just added to?
×
×
  • 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.