Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. make your database field datetime and use: $sqlDate = date('Y-m-d', strtotime($date));
  2. Or in other words: directory traversal
  3. Maybe it's because of that new firewall your company uses that prohibits all it's personnel to upload irrelevant and useless stuff on to the internet
  4. Take a look at my post http://www.phpfreaks.com/forums/index.php/topic,281823.msg1335964.html#msg1335964 It features tweets and people following people You can write that even shorter: $rows = array_map('mysql_fetch_assoc', array_fill(0, mysql_num_rows($result), $result));
  5. What's this for bullshit? Are we now storing a session expiration date on an expiring session? Just use: ini_set('session.save_path', SESSION_SAVE_PATH); ini_set('session.gc_probability', 100);// not recommended but will make sure the session is removed immediatly after expiration session_set_cookie_params(3600);//cookie expires 3600 seconds after initialization session_start(); Another method is using a database as it allows for more control as: SELECT * FROM sessions WHERE id = $id AND last_modified + lifetime > now() This will effectively expire the session when last_modified + lifetime <= now() altough the deletion of the record may well be a few minutes later. It has also other advantages like a session will be re-used instead of creating a new one whenever the user logs-in before the session expires by which the last_modified time is modified and the expiration is delayed
  6. http://reader.google.com
  7. I highly disadvice against the use of integer as an indicator for a user level it's just not readable. Any programmer that will have to maintain your work will have to write down which number stands for which role. A much easier approach is: class User { const ROLE_VISITOR = 1; const ROLE_MEMBER = 2; const ROLE_ADMINISTRATOR = 4; private $data = array(); public function __construct($data) { $this->data = $data; } public function isVisitor() { return $this->_getRole() & self::ROLE_VISITOR; } public function isMember() { return $this->_getRole() & self::ROLE_MEMBER; } public function isAdministrator() { return $this->_getRole() & self::ROLE_ADMINISTRATOR; } private function _getRole() { return (isset($data['role']) && is_integer($data['role'])) ? $data['role'] : self::ROLE_VISITOR; } } // in your script if ($user->isAdministrator()) { Something like that is readable
  8. Then provide some more information or an example of what you want to achieve because I agree with ohdang888 from what I read from you.
  9. Here's a list of a few good forums around http://webtecker.com/2008/05/02/8-popular-open-source-forums/ I highly recommend Vanilla or SMF (which PHPFreaks uses)
  10. Your code should have been: foreach ($array as $key => $value) { unset($array[$key]); } But this is equal to the faster: $array = array();
  11. You were right it is simple look at the below code see something strange? <input type="submit" name="button" id="button" value="Submit" /> if (isset($_POST['submit'])) {
  12. $query = "SELECT data_id, resolution FROM data WHERE tdate = '$date' AND resolution IN ('Resolved', 'Dispatch') ORDER BY resolution"; $result = mysql_query($query); if ($result) { $resolved = array(); $dispatch = array(); while ($row = mysql_fetch_assoc($result)) { if ($row['resolution'] === 'Resolved') { $resolved[] = $row; } else if ($row['resolution'] === 'Dispatch') { $dispatch[] = $row; } } //use $resolved, $dispatch }
  13. Use the BaseUrl view helper <link href="<?php print $this->baseUrl('styles/screen.css'); ?>" .. />
  14. Instead of keeping track of hits manually use Google Analytics instead it provides you with much more information and allows you to set-up funnels and goals http://www.google.com/support/googleanalytics/bin/answer.py?hl=en&answer=55580
  15. If you go for one table like jl5501 suggested you need to make sure that whenever a user adds a product it's listed under a subcategory because if the use is able to place it under a category then your product may well never be shown
  16. Post your database structure
  17. Well if you don't store it in a database then why don't you just create 2 files: summer.inc.php and winter.inc.php $time = time(); if ($time >= mktime(0, 0, 0, 5, 1) && $time <= mktime(0, 0, 0, 31, 10)) { include('summer.inc.php'); } else { include('winter.inc.php'); }
  18. Would someting like Gears work? http://gears.google.com/
  19. create table opening_hours ( id integer not null auto_increment, valid_from date, valid_until date, monday varchar(32), tuesday varchar(32), wednesday varchar(32), thursday varchar(32), friday varchar(32), primary key (id)); $query = 'SELECT monday, tuesday, wednesday, thursday, friday FROM opening_hours WHERE now() BETWEEN valid_from AND valid_until'; $result = mysql_query($query); list($monday, $tuesday, $wednesday, $thursday, $friday) = myql_fetch_array($result, MYSQL_NUM)) { //echo '<td>', $monday, '</td><td>', $tuesday, '</td><td>', $wednesday, '</td><td>', // $thursday, '</td><td>', $friday, '</td><td>'; The fields monday till friday would hold the opening hours like 17:00-24:00
  20. Well I still can get that degree and start working for IBM some day, so you are only spared a few years before cataclysm starts Besides if I won't kill you, time will, or the Sun, or a war between US and China, or Iran, or climate change, or terrorists, or .. 6 million ways to die, choose one!
  21. No this will only center it horizontally and he probably also wants it vertically centered
  22. and, why would you do that? The correct question is: 'why wouldn't you do that?' (and there are actually some valid responses to it). When company allegedly using OO approach to programming does not know benefits of TDD, that doesn't bode well. 'Do you do unit tests?' 'Why would you do that?' 'Do you do encapsulate fields in your classes?' 'Why would you do that?' 'Do you try to make your classes as decoupled as possible?' 'Why would you do that?' 'DRY' 'Wha...?' Why did you become a programmer? I didn't. I just visited the company on open-business day someone assigned me a seat and I'm "working" here ever since. Altough this may be funny now it's what we face almost everyday people which you have to work with who actually have no idea of what they are doing.. I knew I had to get that Engineer Degree and work for IBM
  23. Take a look at: http://www.wpdfd.com/editorial/thebox/deadcentre4.html
  24. Nothing can safe the world we are doomed the entire universe is against us: the sun, our planet, .., everybody! Unit-Testing does not safe the world it discovers bugs early in the development process (atleast if one knows how to apply it). The same applies for Continuous Integration, Acceptance-Testing and Usability-Testing. They help you to create better software for the client and maintainable software for you.
  25. It's not just single programmers it are complete companies I once had an interview with a programmer from another company when I asked them after which methodology they applied and why? He replied: We write OO because it's better.. Completly stunned I asked him if he applied Unit-Testing on which he replied: why would you do that? The companies framework went open-source a few years back and horrifying is an understatement. Something different I also came across is website deployment in less or equal to 3 consecutive days.
×
×
  • 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.