Jump to content

fizix

Members
  • Posts

    50
  • Joined

  • Last visited

    Never

Everything posted by fizix

  1. I'm afraid that wouldn't work for two reasons: 1. The address won't necessarily start with http://, it could be a relative address (sorry, should have specified that) 2. I only want to find strings that start with window.location=
  2. Hey all, I've been playing with this for a while and finally decided to ask the experts. I'm trying to match just the URL in the following strings: window.location="http://www.text.com"; window.location='http://www.text.com'; window.location="http://www.text.com" window.location='http://www.text.com' window.location=http://www.text.com; window.location=http://www.text.com This works for all of them except the last one: /window\.location\=["\']?(.*?)["\';]/i Is there any way to make a regex that works for all of them?
  3. fizix

    Need preg help

    Is your data changing at all? If not you shouldn't even be using regex; you could use strpos().
  4. It may be more efficient to read the whole string in to a PHP string and use square brackets to read each character, like so: $string = 'abcdef'; echo $string[0]; // a echo $string[3]; // d
  5. I use a function like this: function parsesearch($search) { $searches = split(" ", $search); $searchqty = count($searches); for($x=0;$x<$searchqty;$x++) { if(!isset($searchquery)) $searchquery = " WHERE (title_keys.title LIKE '%".$searches[$x]."%' OR ips.domain LIKE '%".$searches[$x]."%')"; else $searchquery .= " AND (title_keys.title LIKE '%".$searches[$x]."%' OR ips.domain LIKE '%".$searches[$x]."%')"; } return $searchquery; } You may need to tailor it to your needs but hopefully it gives you a starting point.
  6. Does the password look like a string of numbers and letters before you change it? If so it could be an MD5 hash (or other hash). If that's the case you'd need to first encode the password to MD5 with a website like this one: http://7thspace.com/webmaster_tools/online_md5_encoder.html
  7. Your query should look like this: $query = "SELECT tourname, lastname from events where tourname like '%$search%' or lastname like '%$search%' Note where I added the $ to or lastname like '%$search%'.
  8. Ok, I've got two tables: Table: ips +-----------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------+--------------+------+-----+---------+----------------+ | id | int(11) | | PRI | NULL | auto_increment | | connect | tinyint(1) | | | 0 | | | ip | bigint(20) | | | 0 | | | domain | varchar(100) | | | | | | title | varchar(250) | | | | | | time | int(11) | | MUL | 0 | | | title_key | int(2) | | | 0 | | +-----------+--------------+------+-----+---------+----------------+ 7 rows in set (0.00 sec) Table: title_keys +-------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+--------------+------+-----+---------+----------------+ | id | int(4) | | PRI | NULL | auto_increment | | title | varchar(250) | | | | | +-------+--------------+------+-----+---------+----------------+ 2 rows in set (0.00 sec) I'm trying to LEFT JOIN the two tables so that title.title_keys becomes the title when ips.title_key matches id.title_keys. In all other instances I'd like it to return ips.title. I've made sure that ips.title is always empty when ips.title_key is not 0. Here is my query: SELECT * FROM `ips` LEFT JOIN `title_keys` ON ips.title_key = title_keys.id However, when I echo mysql_result($recentfound,$x,"title") it only echoes the title from ips.title. I thought if ips.title was blank and title_keys.id matched ips.title_key it would echo title_keys.title. What am I doing wrong?
  9. That's a good idea. I think I'll do something similar such as storing a session variable with the ID of the search that they're currently looking at. Then if they view a different search I'll just reset that variable (and of course it will be reset when they log out).
  10. Ok, I thought this would be an easy one at first but it's turned in to something more complicated than I expected: I have a database that can be searched and I allow my users to save their searches. I want to allow them to view all the new results since they last ran the search. That part is easy... I just save the timestamp for the last time they ran the search to a 'lastrun' column is SQL and update 'lastrun' every time the search is run. However, I run in to problems with multi-page results... When they move to the next page it thinks that the search was run a few minutes or seconds ago so page 2 is blank. My question is: how can I tell when the user is done with his/her search so that I can update the 'lastrun' parameter?
  11. I don't want to create them sequentially but maybe if I assigned each process a group of IP addresses (say 2000 at a time) and then told it to select from that group at random and removed each address I tried from the group as I went it would still be quasi-random and they would all be unique...
  12. Yes, it needs to be random and unique. I'm basically generating a bunch of random IP addresses and I don't want to generate the same one twice. I can't keep a list of addresses I've already generated because I'll have multiple processes running at the same time and the database containing the addresses would get WAY too big WAY too quickly (trust me, I've already tried).
  13. uniqueid gives me no control over the length of the string I'm generating, nor does it guarantee that I would have duplicates.
  14. That didn't help. I changed my test function to this: $test = array(); $starttime = time(); for ($i=0;$i<100000;$i++) { srand($i); if ($runtime % 30 == 0) set_time_limit(200); $number = md5(rand()); if (in_array($number, $test)) { die("Found dupe at iteration number $i<br />\nNumber is $number"); } else { $test[] = $number; } $runtime = time() - $starttime; } And got: Well then you could md5 it with random salts. Example: $test = array(); $starttime = time(); for ($i=0;$i<100000;$i++) { srand($i); if ($runtime % 30 == 0) set_time_limit(200); $salt1 = rand(); srand($i + rand()); $salt2 = rand(); srand($i - rand()); $number = md5($salt1 . rand() . $salt2); if (in_array($number, $test)) { die("Found dupe at iteration number $i<br />\nNumber is $number"); } else { $test[] = $number; } $runtime = time() - $starttime; } Still didn't work. :'(
  15. If it is truely a random number then it will inevitably have duplicates. Does it need to be a large and complex number? Or would just a count work? You could have a table with a single integer autonumber column and just do an insert (of NULL) and then get the last inserted key (in Oracle you could just use a sequence, but MySQL doesn't support them). To stop the table just delete old inserts regularly (possibly triggered by inserts to the table). If you want to mix it up a bit then just hash that number. All the best Keith Wouldn't this basically do the same thing as my for loop?
  16. How can I use uniqid to seed the rand function?
  17. That didn't help. I changed my test function to this: $test = array(); $starttime = time(); for ($i=0;$i<100000;$i++) { srand($i); if ($runtime % 30 == 0) set_time_limit(200); $number = md5(rand()); if (in_array($number, $test)) { die("Found dupe at iteration number $i<br />\nNumber is $number"); } else { $test[] = $number; } $runtime = time() - $starttime; } And got:
  18. Unfortunately I can't do this because I'll have multiple scripts running at the same time and none of them should be generating the same number. I can't store all the numbers in a database either... the database would get way too big way too quickly. Does anybody know of a way to generate a random number, without duplicates, and not log all the numbers that have already been generated?
  19. I hope somebody can help me with this because I'm at wit's end: I have a script that generates a random number. I don't want it to ever generate the same random number twice so I'm seeding the rand function with an incrementing number. However, after a certain point, it generates a duplicate random number anyway. Here's the function to prove it: $test = array(); set_time_limit(200); for ($i=10;$i<100000;$i++) { srand($i); $number = rand(); if (in_array($number, $test)) { die("Found dupe at iteration number $i<br />\nNumber is $number"); } else { $test[] = $number; } $runtime = time() - $starttime; } The output I get when running the script under Apache in Windows is this: However, when I run the script in a Linux environment I don't seem to have the problem (although it times out before it gets to the 200 second time limit). Anybody have any ideas how to fix this? By the way, you'll need to have "suhosin.srand.ignore = Off" in your php.ini file to the code above.
  20. Does anybody have ANY ideas?
  21. Ok, say I'm trying to pull tags from the source of . When doing a print_r on $found I get: Array ( [0] => Array ( [0] => <object width='728' height='90'>"; url += "<" + "param value='clickTAG=" + encodeURIComponent(ref_url) + "' /" + ">"; url += "<" + "embed src='" + img_url + "'"; url += " type='application/x-shockwave-flash' wmode='transparent'"; url += " flashvars='clickTAG=" + encodeURIComponent(ref_url) + "'"; url += " width='728' height='90' /" + ">"; url += "</object> [1] => <object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/Ee_8IMx0uMo"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/Ee_8IMx0uMo" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object> ) ) However, I only want to get the result in $found[0][1], not $found[0][0]. I want to filter it out by excluding strings with semicolons [;] from the results.
×
×
  • 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.