6
votes
3answers
148 views

Can I use this function to store passwords?

Just wrote this function, wondering if it's secure enough to store passwords in a database: public static function hash($salt, $str) { $salt = md5($salt); $salt = ...
2
votes
0answers
60 views

PHP - faster/better implementation of is_dir function for FTP/FTPS connections?

I'm implementing an is_dir() function to determine if a given item is a directory or a file for FTP/FTPS connections. Currently, I have two methods: one using PHP's FTP wrapper for the is_dir() ...
0
votes
2answers
77 views

PHP PDO Custom class ple

i created a database class from a good tutorial and wanted to put it up here so it would get in some search results. it took me about 2 days to find it. also i added a few custom functions to it.. ...
0
votes
2answers
141 views

A better way of writing a PHP function

As the title says, I'm looking for a better way of writing the following PHP function as it's a very very long one. It's part of a bigger class and I'm trying to keep the amount of code as little as ...
0
votes
2answers
94 views

Refactoring functions that generate string with random letters, numbers or mixed chars?

The bellow functions are used to generate a string with random characters, and they have a parameter to specify the string length. The string can be composed of letters, numbers or a conjunction of ...
2
votes
1answer
76 views

Single function to read one, read all, or set

I have the below function, it is designed so I can call: $object->temp('one', 1); //add the key `one` to the temp array with value 1 $object->temp('two', 2); //add the key `two` to the ...
2
votes
2answers
264 views

Best practice for converting minutes and seconds in seconds

I have 2 input fields to input the duration of a CD song. The first input is for minutes and the second is for seconds When submitting the form, I must insert in the db the duration either in seconds ...
3
votes
1answer
86 views

How to improve function to detect the mime type using an agnostic method?

This function is used to get the mime type of any given file. The intended purpose was to have it working within any of our servers that vary from the latest PHP version down to PHP 4. /** * Get the ...
2
votes
1answer
101 views

How can this function to get a remote file improve?

I've prepared a function using cURL to get a remote file to the local storage: /** * cURL - Get Remove File * * Function using CURL the get a remote file to the local storage. * * @param str ...
3
votes
1answer
57 views

How does this function look?

What do you think of my function. It is used to change a cyrillic word with a stress marker into the same cyrillic word but with the stress marker seperately represented as a number. As I want to ...
1
vote
2answers
83 views

How to improve this PHP function to confirm the presence/create directories?

While preparing an automated process to manipulate files, I've made the following function to check for the base directory and sub-directories presence, as to allow or deny the remaining code to be ...
2
votes
1answer
397 views

Passing anonymous functions and getting variables from an outer scope in php

I'm doing something quite strange. I'm trying to create a tiny system for creating templates inline in php, so that I can refactor by creating multiple templates in the original script, and ...
0
votes
1answer
240 views

Is my login function secure ? how to improve it?

Using cakePHP, I would love to have your point of view about this large source code, i am not sure if its enought secure. sha1() will be removed with another script. I found this large script can be ...
2
votes
2answers
368 views

PHP and Custom Functions

I am new to the world of coding as well as XHTML and PHP. As a way to gain more experience as well as to put theory into practice including a way to challenge myself, I put together the following code ...
17
votes
7answers
1k views

Is_numeric_array() missing!

I found that in PHP (or i probably can't find it) a proper is_numeric_array($array) function is missing. So i created one. The problem is that i don't think it's great and i don't know how to improve ...