Jump to content

tibberous

Members
  • Posts

    1,187
  • Joined

  • Last visited

  • Days Won

    1

tibberous last won the day on February 17 2013

tibberous had the most liked content!

Contact Methods

  • AIM
    tibberous
  • MSN
    tibberous@hotmail.com
  • Website URL
    http://www.TrentTompkins.com
  • Yahoo
    tibberous

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

tibberous's Achievements

Advanced Member

Advanced Member (4/5)

4

Reputation

  1. Hey everyone... I'm back.
  2. This is a simple task, but my brain apparently no longer works. I have a nested category structure - each record can have a parent, that is the id of another category. So: id name parent 1 Sporting Goods 0 2 Golf Clubs 1 3 Baseballs 1 4 Shirts 0 All I want to do is write a function that takes an id and gets all the children below it. It should be like 2 functions, with one being recursive... like 10 lines total... function has_subcategories($catid){ $result = $this->db->query("select * from `categories` where `Owner`=$catid and `active`=1 and `deleted`=0"); return $result->num_rows() ? true : false; } function get_subcategories($catid){ $result = $this->db->query("select * from `categories` where `Owner`='$catid' and `active`=1 and `deleted`=0"); $children = array(); foreach($result->result_array() as $subcat){ //echo $subcat['id'].'-'.$this->has_subcategories($subcat['id'])."<br>"; if($this->has_subcategories($subcat['id'])){ $children = array_merge($children, $this->get_subcategories($subcat['id'])); } else { $children[] = $subcat['id']; } } return $children; } Anyone see what I'm doing wrong? I've wrote this exact function before, not sure how I'm screwing it up.
  3. Godaddy sucks as both a web host and a registrar. MediaTemple also kind of sucks (godaddy bought them) Moniker is a good registrar.
  4. The advantage to using unescaped is that it at least shows you looked and made a consious decision to use unescaped data. Also, if you implement others code, you can replace their $_REQUEST's as needed.
  5. I normally hate best practices, but this one I came up, so it's less bad. Basically, you create a few functions like: function ireq($x){ return intval($_REQUEST[$x]); } function req($x){ return mysql_real_escape_string(trim($_REQUEST[$x])); } function unescaped($x){ return $_REQUEST[$x]; } Next, NEVER use $_REQUEST Now, to check your site for SQL injection holes, you can just search for $_REQUEST and "unescaped(". You can even use this method to slowly rewrite other peoples code, by replacing each $_REQUEST and making sure the proper characters are escaped. Has the added benifit of being MUCH fast to type - $i = req('i') vs $i = mysql_real_escape_string($_REQUEST['i']);
  6. Go post the url on 4chan. Don't say you want to test the security, just tell them it's your first PHP site and that your sure it's hacker-proof.
  7. <table><tr><td style='height:100px' valign='middle'>This is the middle.</td></tr></table> Theres some shitty hacks you can do to get it to work with divs, but since tables have had vertical align for the last 15+ years, I'd just use them.
  8. You acctually need some pretty advanced knowedge to do this. First, getting a PHP script to run at set intervals takes chron daemon (typically, I know there are other ways) You probably don't need curl. Unless your doing stuff like spoofing cookies and post variable requests, you can just do: $file = file_get_contents("page.php?p=1&section=whatever"); Biggest thing is probably going to be regex though. Btw, you might want to see if the news site has an rss feed that would be easier to parse.
  9. I have a MySQL set. I could query it as a string and do string compare, but I'd kind of rather get it as an i and do bit comparision. So... how do I do that? I know: select `permissions`+0 Will give me the decimal value of the set. How can I check to see if a bit is on or off though?
  10. A concept thats obvious to everyone but them. Windows 98 got destroyed for years because they tried to integrate ActiveX, IE and the operating system -- then they stuck in 1001 security prompts, like the problem was users running files and not the security holes that let websites run compiled code. Hopefully enough people will switch Microsoft will eventually quit developing it. They could preinstall Chrome on Windows 8, change the default search provider to Bing, and save a few million a year in development costs.
  11. I'd say thats true if you don't look at IE - I still get stupid things breaking in IE, like the third level of my dropdown menus and border styles on inputs and just general spacing. Maybe IE10 is better - don't feel like spending 20 minutes and a reset to upgrade though.
  12. Yeah - Firefox can't update without breaking plugins, I went like 4 months without Firebug. And no, theres no question, I though I was posting in Misc actually.
  13. You don't turn error reporting on in your editor, it's a feature in PHP that you turn on in the php.ini file. The path to you menu starts with this: inc/incfiles/ which means it needs to be in a folder called incfiles in a folder called inc.
  14. ROFL! Have you tried opening it in UEStudio or Word to make sure there aren't end of line characters in the file? You gotta fix it to really be able to work on it - even if it takes you 20 minutes to indent by hand, just do it or find some better code to start from.
×
×
  • 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.