Jump to content

marcbraulio

Members
  • Posts

    60
  • Joined

  • Last visited

About marcbraulio

  • Birthday 02/12/1991

Profile Information

  • Gender
    Male
  • Location
    Kearny, NJ

marcbraulio's Achievements

Member

Member (2/5)

0

Reputation

  1. The reason being is because I am working on a application that will dynamically generate new emails based on existing emails. Instance: example@example.com will generate exam_Ne3u7Ir@domain.com, "Ne3u7Ir" being a hash of the original email "example@example.com". Understood, I'm not really interested in converting it to Hex as I can further shorten this output if it is numeric. So to clarify, what are the odds of Crc32() producing the same "32-bit integer" for two different emails? 1 in 2^32?
  2. Hi, I am a bit confused about when and how to use crc32(). I am looking for a method to hash email addresses, security is not really important, but the hashes do have to be unique and as short as possible. Originally, I thought that the crc32() function returned a hash with both letters and numbers, but it only seems to return numbers. Instance: crc32('example@example.com'); // output 875998594 crc32('exampleexampleexampleexampleexampleexampleexample@example.com'); // output 1225065599 How is it possible that it will always output a 9-digit or 10-digit no matter the length of the string? What are the chances of collision? For as long as the string is unique will it output a unique 9-digit or 10-digit number? Will it ever output letters as well? I am working on 64-bit system, will this output change in a 32-bit system? I have read a few articles and the php manual on it, but I am still some what clueless if this will in fact fit my needs.
  3. Hello everyone, From a security stand point, what are the differences between these two queries? $calories = 150; $colour = 'red'; $sth = $dbh->prepare('SELECT name, colour, calories FROM fruit WHERE calories < :calories AND colour = :colour'); $sth->bindParam(':calories', $calories, PDO::PARAM_INT); $sth->bindParam(':colour', $colour, PDO::PARAM_STR, 12); $sth->execute(); and $calories = 150; $colour = 'red'; $sth = $dbh->prepare('SELECT name, colour, calories FROM fruit WHERE calories < :calories AND colour = :colour'); $sth->execute(array(':calories' => $calories, ':colour' => $colour)); Essentially they do the same thing, but does the addition of "Bind Parameters" add an extra layer of security? I am currently using the latter method.
  4. Hi, I am trying to store the view rate of articles so that I can retrieve them later on by "the most popular". I have searched around but cannot find a straight answer. Can anyone point me towards the right direction? Edit: Never mind, I was over complicating the logic behind this.
  5. Awesome, I'll definitely check it out. Coincidentally the CMS I am building for my own use is based on my experienced with Joomla and Codeigniter. So far I been using Joomla's way of getting the controller and method, probably should have went towards Codeigniter for that one. The reason I got Joomla's concept involved was because I very much like their folder structure, frontend/backend separation, and system of organizing components and modules while utilizing the MVC architecture, which is something that I really believe Codeigniter is weak in, even with the "HMVC" plugin. I am putting it up on GitHub soon, I'll send you the link if you would like to take a look at it.
  6. Interesting, I am going to do a little more research on that. Many thanks for the great insight, this is exactly what I was looking for.
  7. Thank you for the explanation, some how I thought it was the other way around. I now see that my way would never work unless every link was redirected. Would you know exactly how Wordpress deals with multiple components while still keeping the link free of component declarations? If I understood your post correctly, they either: 1. Assume that for any link without a component declaration, like so: (www.example.com/how-to-use-examples) is automatically referring to the article component and therefore the slug is automatically searched for in the article database, if no article is found an error would show. While every other component would require a component declaration, like so: (www.example.com/store/men-blue-jeans) to avoid being searched for in the article database. or 2. Check each component for the slug, like you posted above: if (slug exists in article component) { .... } else if (slug exists in store component) { .... } else if (slug exists in contact component) { .... } But this method seems to be insanely inefficient, wouldn't you agree? As a side note: I think I'll avoid using IDs as I think that the chances of a duplicate titles will be slim. Besides for 99% of the cases, it wouldn't make any sense for me to create two different articles with the same title. Avoiding duplication in general is a good habit for SEO anyway...
  8. Thank you for the quick reply This is a response to which question? I am aware of that, that's what I meant by "Finally remove 'index.php?comp=article&view=category&id=1&/' from the url using .htaccess", I plan to use mod_rewrite. The slug has to be in the url for mod_rewrite to work with it, am I correct? That's why I am adding it in the second step. I am trying to accomplish this: http://www.example.com/this-title-was-converted-to-a-slug Rather than this: http://www.example.com/article/category/1/ Please let me know if I have this concept wrong.
  9. Hey everyone, I am attempting to find the best method to dynamically create seo friendly urls. This is my plan: Original url: http://www.example.com/index.php?comp=article&view=category&id=1 Make slug from the page's title and add it to url: http://www.example.com/index.php?comp=article&view=category&id=1&/this-title-was-converted-to-a-slug Finally remove "index.php?comp=article&view=category&id=1&/" from the url using .htaccess: http://www.example.com/this-title-was-converted-to-a-slug My questions are: Is there a better strategy/technique for accomplishing this? I have done a lot of research and this seems to be the most popular method. Also since I couldn't do directly put a forward slash right after "&id=1", like so "&id=1/this-title-was-converted-to-a-slug", I went ahead and added a "&" right after the id number, like so "&id=1&/this-title-was-converted-to-a-slug". Is this the correct way of doing this? Any suggestions are appreciated, thank you!
  10. And this is when I exit the room in shame... lol
  11. Simply perfect. Many thanks! Pikachu2000's solution worked out perfectly, but I am curious about this method that you mentioned, could you elaborate by giving me an example? Yeah I was about to say, "isn't technically Pikachu2000's solution a MySQL date function?" lol Thanks anyway!
  12. Well, what do you have on line 1? Check for any missing/misplaced semi-colons, parenthesis, or quotes.
  13. Hello everyone, I am trying to convert dates directly from the database but still keep it within the same array so that I can conveniently access it later on. I am not sure how to explain this better, but I believe the code is pretty self explanatory: $stmt = $this->db->query("SELECT title,slug,content,author_id,created FROM article"); $stmt->setFetchMode(PDO::FETCH_ASSOC); $i = 0; while($var = $stmt->fetch()) { $this->data[] = $var; $this->data[$i]['date'] = date("F j, Y", strtotime($var['created'])); $i++; } print_r($this->data); /* produced array Array ( [0] => Array ( [title] => PHP Security Book [slug] => php-security-book [content] => Lorem ipsum dolor sit amet, consectetur adipisicing elit. [author_id] => 3 [created] => 2012-03-13 12:34:42 [date] => March 13, 2012 ) [1] => Array ( [title] => Something To Do [slug] => somthing-to-do [content] => You know what a dolor sit amet, consectetur adipisicing elit. [author_id] => 3 [created] => 2012-03-13 12:35:46 [date] => March 13, 2012 ) ) */ I access it like so: foreach ($_data as $var) { echo '<h2>' . $var['title'] . '</h2> <br />'; echo '<b>' . $var['date'] . '</b> <br />'; echo '<p>' . $var['content'] . '</p> <br />'; } It works perfectly but my question is: Is there a better or more efficient way to do this? I think that my while loop could use some improvement. I was also thinking of maybe fetching the results into a class using PDO::FETCH_CLASS, but it seems like a bit of a hassle for just one modification.
  14. I am not an expert and the way I learned CRUD was by using PDO prepared statements, so I am not 100% familiar with the original mysql format. But as far as I know, to achieve what you want, you would have to do the following: $stores = array("$MktName", "$address"); mysql_query("INSERT INTO stores (name, address) VALUES("implode(',', $stores)") or die(mysql_error()); Because with your current code you are producing this: mysql_query("INSERT INTO stores (name, address) VALUES('address', '$address') or die(mysql_error()); mysql_query("INSERT INTO stores (name, address) VALUES('name', '$MktName') or die(mysql_error()); And that makes no sense since the Columns have to match the Values. Instance: $stores = array("$MktName", "$address"); mysql_query("INSERT INTO stores (name, address) VALUES("$MktName", "$address") or die(mysql_error());
×
×
  • 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.