Jump to content

phpmaster57

New Members
  • Posts

    4
  • Joined

  • Last visited

phpmaster57's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. So, 100MB is equal to 100000000 Bytes (in decimal), and 104857600 Bytes (in binary), for PHP which version would we use for checking max filesize. My current function: public function convertToBytes($from){ $number=substr($from,0,-1); switch(strtoupper(substr($from,-1))){ case "K": return $number*1024; case "M": return $number*pow(1024,2); case "G": return $number*pow(1024,3); case "T": return $number*pow(1024,4); case "P": return $number*pow(1024,5); default: return $from; } } This function converts 100MB to 104857600 bytes. But when comparing it against $_FILES['file']['size'] it will allow the user to upload a 104MB file instead of 100MB file how can we fix this?
  2. So what is the point of array_flip() on $fields, when you can pass in a normal array such as: ['username','pass','email'] to $fields.
  3. So I am looking at the code for https://github.com/vlucas/valitron/blob/master/src/Valitron/Validator.php a validation library, and currently trying to interpret the code. Most of it I understand but a part in the constructor is confusing me. It is as follows: public function __construct($data, $fields = array(), $lang = null, $langDir = null) { // Allows filtering of used input fields against optional second array of field names allowed // This is useful for limiting raw $_POST or $_GET data to only known fields $this->_fields = !empty($fields) ? array_intersect_key($data, array_flip($fields)) : $data; The part that is confusing me is the $this->_fields line, what exactly is the point of this and could you provide an example for when this when be needed? The part that really gets me is when it gets to array_intersect_key and array_flip, again what is the point of these?
  4. Hi everyone I have a security question, first to let you all know I am using the PHP framework, Codeigniter. For one of the features I am making I am using the Jquery tag-it plugin, http://aehlke.github.io/tag-it/ I am then storing the values from tag-it feature into my database. I have not fully made the functionality yet but here is what I was going for: $tags = $this->input->post('tags'); $interests = implode(',',$tags); $updateData = array( 'tags' => $interests ); $this->ion_auth->update($this->ion_auth->user()->row()->id, $updateData); So the above code would turn the array into a string separated with a comma and store it in the database. And then use PHP explode to turn it back into an array. I have not really read the tag-it documentation but what if somebody was able to bypass the tag-it and enter a comma as a value would that mess the explode function up or would it just return an empty value? So if this made any sense what I'm really asking is there a safer way to store and retrieve these values, if yes how so?
×
×
  • 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.