Jump to content

CroNiX

Staff Alumni
  • Posts

    1,469
  • Joined

  • Last visited

  • Days Won

    12

Everything posted by CroNiX

  1. That looks pretty good except it doesn't capture/replace MCCONNELL -> McConnell [C should be capitalized] MACDONALD -> MacDonald [D should be capitalized] I think I can come up with a regex for those cases individually, but can these all be combined into one statement? I can do basic regex, but Im a noob to them and don't know the advanced stuff. I think regex is the hardest thing in a language to learn. I appreciate your effort on this.
  2. I was wondering if anybody had a handy regex for a preg_replace that could be used to format a last name. I need to convert things like: SMITH -> Smith (um, easy) SMITH-JOHNSON -> Smith-Johnson (for the feminists ) MCCONNELL -> McConnell MACDONALD -> MacDonald O'CONNOR -> O'Connor and any combination of the above, like: O'CONNOR-MACDONALD -> O'Connor-MacDonald Any help would be appreciated. Im not sure if this can be done in a single regex as I have yet to master them. Thanks.
  3. Did you put it in the head of your document? Look for: </head> replace with: <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" /> </head> For this to work you must have your icon (in this case its called favicon.ico) in your ROOT directory of your site or adjust the path accordingly (/favicon.ico). If this is done and its not working, there is a possibility that the icon itself is wrong. Google 'favicon.ico' and you will find a ton of info on how to properly create them and set them up.
  4. No, the functionality is totally handled by the browser...You cant change anything about how its handled. The only thing you can do is: <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" /> and thats all.
  5. Posting your code would be helpful.
  6. as haku stated, this is a browser feature, and not all browsers handle it the same way. There is nothing that can be done to make it work in all browsers. All you can do is define one.
  7. I think that's general consensus by now. Its also been the w3c standard for at least 6 years, so it should be everyone's consensus.
  8. Based upon the loading time it probably is AJAXed in though. Yes it is, you can see the requests in firebug.
  9. Its just a custom tooltip. You can do it easily with jquery/mootools/etc.
  10. Nothing to do with what you are asking, but I was wondering why you have this line <div id='ad'><script type='text/javascript' src='http://jserve.performancingads.com/js/perfads.js?r=6415'></script></div> BETWEEN the </head> and <body> tags and not just put the script part within the head? Have you done any promoting of your site? How is your google ranking? Sites just don't get popular by themselves unless its totally unique and fills a niche.
  11. probably just decimal. DECIMAL(10,5) would mean 10 digits, 5 of them for the decimal xxxxx.xxxxx
  12. Personally I would just use AJAX for this. If you are using a decent framework like mootools/jquery it would be simple. You can even grab a table from a page by using its ID and not have to parse the whole page or use a lot of php code filtering what you don't want to appear.
  13. CroNiX

    Porn Site

    Have a goooood lawyer on retainer. A friend did go down this road about 10 years ago, and the amount of cc fraud drove him crazy and kept the lawyers busy. Better have iron clad (no such thing) contracts in place too. Its not as glamorous as you are imagining.
  14. Are you kidding? It is the absolute best time to buy...stocks are way down right now across the board. They will only go up long term. Short term is another deal, but if you're investing short term you gotta really know what your doing. Investing is for long term...by definition. I put 10% of everything I make in stocks/bonds/mutual funds. I will take some out soon to buy my first house...outright! No loan. Will save a lot of money on taxes as well since its my first house. Its a damn good time to buy a house as the housing market is very depressed. The prices are very low and there are tons of houses being foreclosed on. Its a very good time for stock purchasing. It will be even better as the economy keeps sliding, which it will for a time.
  15. I have been tinkering around with this class and just can't get it to work. Everything works like its supposed to EXCEPT it does not retain the session data when going from one page to the next. When I add a session variable ($_SESSION['foo']='bar') I can see it getting inserted into the database and can see it when doing a var_dump($_SESSION), but when I go to another page the data is wiped out of both. I had been reading if you use php5 (which I am) you need to use register_shutdown_function('session_write_close'); to preserve the data because PHP5 destroys the object and doesn't properly close the session if using it in a class. I have used register_shutdown_function('session_write_close'); in both the __construct() and __destruct() methods, but it doesn't seem to help. If I need to post the database class I will, although I don't think the problem is there as I use it a lot. Yes, I instantiate the database class and the session class at the top of every page. $db = new MySQLiDB(HOST, USER, PASS, DBNAME); $session = new SessionManager($db); Any help would be greatly appreciated. Ive been banging my head for too long over this and I am pretty much a OOP noob, so Im drawing a blank. Thanks! <?php /* CREATE TABLE `sessions` ( `session_id` varchar(100) NOT NULL default '', `session_data` text NOT NULL, `expires` int(11) NOT NULL default '0', PRIMARY KEY (`session_id`) ) TYPE=MyISAM; */ class SessionManager { private $life_time; private $db; public $sessid; function __construct($db_object) { // Read the maxlifetime setting from PHP $this->life_time = get_cfg_var("session.gc_maxlifetime"); $this->db = $db_object; // Register this object as the session handler session_set_save_handler( array( $this, "open" ), array( $this, "close" ), array( $this, "read" ), array( $this, "write"), array( $this, "destroy"), array( $this, "gc" ) ); register_shutdown_function('session_write_close'); session_start(); } function open( $save_path, $session_name ) { global $sess_save_path; $sess_save_path = $save_path; // Don't need to do anything. Just return TRUE. return true; } function close() { return true; } function read( $id ) { // Set empty result $data = array(); // Fetch session data from the selected database $time = time(); $newid = $this->db->escape($id); $this->sessid = $newid; $sql = "SELECT `session_data` FROM `sessions` WHERE `session_id` = '$newid' AND `expires` > $time"; $rs = $this->db->query($sql); if($this->db->numRows($rs) > 0) { $data = $this->db->fetchAssoc($this->db->rs); $this->db->closeRS(); } return $data; } function write( $id, $data ) { // Build query $time = time() + $this->life_time; $newid = $this->db->escape($id); $this->sessid = $newid; $newdata = $this->db->escape($data); $sql = "REPLACE `sessions` (`session_id`,`session_data`,`expires`) VALUES('$newid', '$newdata', $time)"; $this->db->query($sql); return TRUE; } function destroy( $id ) { // Build query $newid = $this->db->escape($id); $q = "DELETE FROM `sessions` WHERE `session_id` = '$newid'"; $this->db->query($q); return TRUE; } function gc() { // Garbage Collection // Build DELETE query. Delete all records who have passed the expiration time $sql = 'DELETE FROM `sessions` WHERE `expires` < UNIX_TIMESTAMP();'; $this->db->query($sql); // Always return TRUE return true; } function getSessid(){ return $this->sessid; } public function __destruct(){ session_write_close(); } } ?>
  16. You wouldn't be storing the MD5 values in the database, only using them to check. As I mentioned, you would of course need to properly escape things when doing an insert. $user=md5("Fred"); $SQL = "SELECT * FROM users WHERE users.name = MD5('Fred')"; Since you are retrieving the values, including the user name, you would be able to display the proper user name as its not STORED hashed. Its only checking the hashed value in the WHERE clause.
  17. I was doing some research and came across an interesting idea for preventing SQL injection, and just thought I'd run it by everyone for thoughts. Yes, I know about mysql_real_escape_string and other methods, but this was just interesting to me. Ill give a small example using a simple login checker. //assign the md5 hash of the username and password $name = md5($_POST['username']); $pass = md5($_POST['password']); //in the SQL statement, check the MD5 values of the fields $sql="SELECT * FROM users WHERE users.username = MD5('$name') AND users.password = MD5('$pass')"; ... Theoretically you wouldn't need to run any sort of validation on the username and password as it takes the hashed value so any bad sql/javascript/etc statements would not be present. Obviously you would need to do the checking on inserts, but if you are using it in a select would this be acceptable? What say you?
  18. Try <?php phpinfo(); ?> instead of <?phpinfo()?> If that works short tags (<?) are probably turned off (like they should be) in your php.ini
  19. This is what you want to use to see if you got a result: http://us.php.net/manual/en/function.mysql-num-rows.php
  20. I have a voter registration table that has 2.8 million entries. It takes about 4 minutes to search for a name to see if it exists. I was thinking to split the table into 26 separate tables for each letter of the alphabet to speed things up. I haven't had to do anything like this before and I'm wondering if its possible to do this with a single query (or 26) instead of having php do it. Something like: and insert all the data into a new table (which would have the identical structure of maintable) table_a? then do the same thing for b and c and so on. Is this possible to do in a single query? I'm guessing yes but have not as of yet been able to find a solution. Thanks for any help.
  21. If you use an illegal key, or generated key, or whatever, your customer will no longer be able to use any microsoft updates as it will report it as an invalid key. Then they might report YOU to microsoft as the one who gave them that key.
  22. $words = array(); // do your stuff...then later $words[] = "hello"; // $words[0] will be 'hello' $words[] = "goodbye"; //words[1] will be 'goodbye' //loop through all of the words and print each one out on a separate line foreach($words as $word) { echo "$word<br />"; } Hope that helps.
×
×
  • 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.