Jump to content

50r

Members
  • Posts

    57
  • Joined

  • Last visited

About 50r

  • Birthday 02/17/1978

Contact Methods

  • Website URL
    http://50r.co.za

Profile Information

  • Gender
    Not Telling
  • Location
    South Africa

50r's Achievements

Member

Member (2/5)

0

Reputation

  1. what i was trying to ask was, i am working on a system that will manage tenants so tenant on their registration, need to pick a subscription cycle which can be monthly,quarterly semi-annuall, and annualy. what i did not know is that there were such simple functions like mktime and the date(t) format. But my intent in this question was the ability to add up a three or six or monthly cycle regardles of the numbers in the month but just bind it all in just a simple variable monthy, quarterly and soo on. thanks to you guy good bless. .
  2. Thanks for the quick replay i also found this one which also works perfectly fine. function get_days_in_month($month, $year) { return $month == 2 ? ($year % 4 ? 28 : ($year % 100 ? 29 : ($year %400 ? 28 : 29))) : (($month - 1) % 7 % 2 ? 30 : 31); }
  3. I am working on a tenance script that will need to know how many days are in the current month and also to check if the current february is not in a leap year. this is the code that i was trying to use but is there any better way to handle this? $month = strftime('%m'); $year = strftime('%Y'); if ($month == 1 || $month == 3 || $month == 5 || $month == 7 || $month == 8 || $month == 10 || $month == 12) { $days = 31; } elseif ($month == 4 || $month == 6 || $month == 9 || $month == 11) { $days = 30; } elseif ($month == 2) { if(($year % 4 == 0) && ($year % 100 != 0) || ($year %400 == 0)) { $days = 28; } else { $days = 29; } } echo $days;
  4. I dont understand the question. are you asking why the " still show up in the echoed string from the database even though it was escaped on insert? if thats the question then the answer is escaped values are handled differently depending on a dbms that you are using. but if you escape a string, you are telling the dtatabase not to use the " for sql execution rather egnore them and save the string as a normal string. thats why when you sometimes echo an escaped string from a database, it will display with the " on. the escape function dont strip the " but does inform the database as i have explained above. thanks.
  5. http://crackstation.net/hashing-security.htm the last time i checked that site it was down but it has a very good tutorial on how to hash and sal a password. i use there sample code but it will be better if you read from him first on how he explains that code. public static function create_hash($password) { // format: algorithm:iterations:salt:hash $salt = base64_encode(mcrypt_create_iv(PBKDF2_SALT_BYTES, MCRYPT_DEV_URANDOM)); return PBKDF2_HASH_ALGORITHM . ":" . PBKDF2_ITERATIONS . ":" . $salt . ":" . base64_encode(self::pbkdf2( PBKDF2_HASH_ALGORITHM, $password, $salt, PBKDF2_ITERATIONS, PBKDF2_HASH_BYTES, true )); } private static function pbkdf2($algorithm, $password, $salt, $count, $key_length, $raw_output = false) { $algorithm = strtolower($algorithm); if (!in_array($algorithm, hash_algos(), true)) die('PBKDF2 ERROR: Invalid hash algorithm.'); if ($count <= 0 || $key_length <= 0) die('PBKDF2 ERROR: Invalid parameters.'); $hash_length = strlen(hash($algorithm, "", true)); $block_count = ceil($key_length / $hash_length); $output = ""; for ($i = 1; $i <= $block_count; $i++) { // $i encoded as 4 bytes, big endian. $last = $salt . pack("N", $i); // first iteration $last = $xorsum = hash_hmac($algorithm, $last, $password, true); // perform the other $count - 1 iterations for ($j = 1; $j < $count; $j++) { $xorsum ^= ( $last = hash_hmac($algorithm, $last, $password, true)); } $output .= $xorsum; } if ($raw_output) return substr($output, 0, $key_length); else return bin2hex(substr($output, 0, $key_length)); } public static function validate_password($password, $good_hash) { $params = explode(":", $good_hash); if (count($params) < HASH_SECTIONS) return false; $pbkdf2 = base64_decode($params[HASH_PBKDF2_INDEX]); return self::slow_equals( $pbkdf2, self::pbkdf2( $params[HASH_ALGORITHM_INDEX], $password, $params[HASH_SALT_INDEX], (int) $params[HASH_ITERATION_INDEX], strlen($pbkdf2), true ) ); } private static function slow_equals($a, $B) { $diff = strlen($a) ^ strlen($B); for ($i = 0; $i < strlen($a) && $i < strlen($B); $i++) { $diff |= ord($a[$i]) ^ ord($b[$i]); } return $diff === 0; }
  6. There are two problem actually why no one has replyed to this post. 1 your question is quite not clear, 2 the code that you post is not well indented which makes it hard to read. Try by explaining what the problem is. do you want to retrieve data from a database? after you insert it or what?
  7. hello guys this seems simple but not in my case as per now. i have a table of categories with cat_id -------------------cat_parent_id----------- cat_name 7 ------------------------- 0 ---------------------- cat1 9 --------------------------- 0----------------------- cat2 11 -----------------------------7------------------------ cat3 now am using these categories as a menu on the front page. i have made a query that calls only cats that have a 0 for parent thats fine. in this case cat1 and cat2 are the main menu. i want to have an icon on a category that has a child which is cat3 that will show a user that if they point a cursor there, they will see hiden childrens. the proble is am on a home page that has no query in the url that i can use as a reference in my sql query. what kind of query can i do to put an icon on cats that have a child? before even a use clicks on it.
  8. Hey freaks i want to be sure on this, do are constants binded to global and local scopes like valuables? i see one code of my friend using constants in a class method but i dont see where he declairs them global. but they are defined from an included config file.
  9. i understand thanks guys maybe i am just being un petient.
  10. Hello freaks this has got me trying to figure out how to get the number of row using the select conunt() but i cant figure it out. here is the code $sql = mysql_query("SELECT COUNT(*) FROM tbl_menu WHERE module = $id"); if(!$sql){echo "there is an error".mysql_error();} I just want to catch the number of row as a result.
  11. this is not only going to depend on your php code, but it will also involve the structure of your database. make sure you understand what a word relational in database means.
  12. what are you trying to do? do you have a class inside a class? do you know anything about class referencing? extends?
  13. Thanks it was such a stupid biggner mistake. hope it helped @ arunpatal
  14. Hello freaks, many of the sites that i get dont seem worth spending money and time as they explain it cleary that their courses are durated for some 5day some 30 day i call that money waste and time waste. does any one of you good freaks know of any instution that offers an online instructor led advernced php course?
×
×
  • 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.