Jump to content

Kemik

Members
  • Posts

    83
  • Joined

  • Last visited

    Never

Everything posted by Kemik

  1. Hello, I'm coding a budget application. Basically, the section of code I'm working on will check if today is the start of a new week and if so it will add the weeks budget to the current balance. If today is > next week date fetch budgeted amounts per week from each category and current balance update category balance with current balance + budgeted amount update next week date for next coming sunday This piece of code will run every time the user visits the homepage. (Would this be easier to just use cron jobs?) I'm stuck on what happens if the user doesn't visit the site for two weeks. It will only add one weeks budget to the balance. Also, how would I calculate the date for the next coming sunday? I cannot use date + 7 as the user could visit on a tuesday, wednesday, etc. Thanks.
  2. Oh thanks! Never heard of that function. Should be easy enough to make the fixtures from there. 5. Use shuffle function. 6. $nofixtures = $maxusers / 2 7. Loop for $nofixtures create a new fixture with incremental $fixture_id, $userone = incremental user, $usertwo = next user in the array. I'm going to do a bit more searching for the loops so I don't have much experience with loops and getting incremental information so feel free to post suggestions.
  3. Hello all, I’m building a tournament system and I’m going through the planning stages, specifically making the psuedo code. I’m trying to think how I would take a list of players, add a number of passes if there are spaces left (total spaces - number of users signed up) and then randomise who each user plays against. The system is using user_ids to identify users. So, on click of “Make fixtures” the following occurs: 1. Get $maxusers and $nosignedup. 2. $passes = $nosignedup - $maxusers. 3. Get array of users ($users [user_id]) 4. A loop to add a user with the user_id of -1 for each pass to $users array. Here’s where I’m stuck. I need to randomise the user_id in the array and then some how make fixtures for the tournament. E.g. if the tournament has max users of 8 it will make 4 fixtures. Any ideas would be appreciated.
  4. I'm using CodeIgnitor. I don't think it's affected though. I just used the $this->input->post('date') to get the textfield called date. When I echo $this->input->post('date') it comes out with the input as it should. It's just like $_POST['date']. My data is being stored as DATE in a MySQL database. Feel free to test it here. I've stopped it inserting to the database. It will just return the values. Here's the insert code: $insert = array( 'date' => $this->input->post('datetime') , 'details' => $this->input->post('event') ); $this->db->insert('one_events', $insert); The event text gets inserted but the date doesn't.
  5. Hello, The user types a date (dd-mm-YYYY) in to a text field, the date is checked against a regex and if it passes, is then inserted to a database. For some reason inserting the date ($this->input->post('date')) directly in to the database gives the default for the field (0000-00-00). I've tried doing date("d-m-Y", $this->input->post('date')) but get 1970-01-01 or something like that. Do you have any advise for converting the text field input in to a format that can be inserted in to the database?
  6. Kemik

    Date regex

    Hello all, I'm trying to create a regex which only allows dates in the following format: dd-mm-yyyy So I can insert it in to my database (DATETIME). if(!eregi("(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d", $str)) { $this->validation->set_message('datetime', 'The %s field must be in this format: dd-mm-yyyy'); return FALSE; } else { return TRUE; } If I try it, I get the error The datetime field must be in this format: dd-mm-yyyy. Can anyone see where I'm going wrong? Thanks.
  7. Hello, I'm creating a calendar and want to display one form if the user selects One-time-event from a drop down menu or display a different one if they select Daily. The only thing that really changes is that for one-time-event text field called date is displayed and if it's daily a drop down menu with the days of the week is displayed. I've had a look around google but cannot really find anything that could help me. Thanks for the help.
  8. Hello, I'm thinking about the structure of the database/code for a calendar application I want to make. How would be best to store events that occur once a week/month/year? I couldn't really create a separate entry for each time it occurs as there could be 52 events (once a week) / insert queries. Thanks for the help.
  9. Solved <?php if (date("Y-m-d", strtotime($row->datetime)) == date("Y-m-d")) { $datetime = date("H:i", strtotime($row->datetime)); } else { $datetime = date("d/m/Y H:i", strtotime($row->datetime)); } ?>
  10. Hello all, Can you check this code and tell me where I'm going wrong please? <?php if ($row->datetime == date("Y-m-d")) { $datetime = date("H:i", strtotime($row->datetime)); } else { $datetime = date("d/m H:i", strtotime($row->datetime)); }?> I'm unsure how I would do the if part of the statement as the datetime is in SQL Datetime format. I know I need to say its strtotime but I'm not sure where to put it.
  11. I need them to stay with me. It's a CMS that I coded and I don't want them taking it to another host. They wouldn't have file access anyway.
  12. Thanks dbo. For querying the permissions would I just Select all group_ids from User_Group where user_id is $user_id. Then Select permission from permissions where group_id = group_id from previous query? If permission = allow then continue, if not show error. How would you handle clashes? E.g. a user is in two groups, one allows access to edit news the other is denied. Really the user should be allowed as they are allowed in at least one group. Not sure how I'd code that though. Finally, how would you store the users permissions in the session, so you dont have to constantly query the database?
  13. Hello, I'm creating a CMS where users sign up and they're given a subdomain with my CMS installed. They can then edit at will, users sign up, etc. I'm looking in to two options for managing the files for the CMS. 1. Store each CMS copy in it's own folder, database, etc. (Basically a whole cPanel account per CMS). 2. Store the files centrally. Possibly create seperate databases or do something else using one. Option one will be harder to maintain and update. As if I make one update with the files I have to manually do each CMS. Option two is easier to maintain, however managing how the CMS gets it's site title, content, etc is harder as each user may have their own theme, logo, etc. How would you advise I could do this? I'm not thinking about thousands of CMS installs, but possibly hundreds (100 - 300) if it takes off.
  14. Yes, that's what I'm working off, but I'm not sure how to lay this one out. The user can only be in one admin group, but can also be a member of a clan and then have certain permissions for a clan. How would I layout a database for this? At the moment I have users, clans and clan_members tables.
  15. Hello, I'm creating a fairly complicated user system. A user can be one of the following, with each group given different permissions. Admin Groups Site Admin (root) General Admin News Admin Competition Admin Referee Site User Users and admins can also be a member of a clan (aka team) Clan Permissions Clan Leader (all clan permissions) Clan Member Manage Applications Manage Fixtures User awaiting member approval E.g. Bill is clan leader and has access to all clan actions. Bob is a clan member with the ability to manage applications. Fred is a clan member with both manage applications and manage fixtures. As you can see, it's sort of a two tier permission system. A user can only be one of the "Admin Groups" but can also (optionally) be one of the "Clan Permissions". How would I organise all of this? Database side and the pseudo design for the coding. Thanks for your help.
  16. Hello, I want to do a query which selects the config.maps table.field WHERE ladder_id = $ladder_id. I can do this fine, but the next bit is slightly harder. The maps are stored as an array, separated by commas. I can explode these commas to put the maps in to an array called $maps but how can I then check that a value inputted from the drop down menu matches one of these maps? I cannot do: if ($dropdown = $maps[1] || $dropdown = $maps[2] || $dropdown = $maps[3]) { // Continue } As there could be anywhere between 1 and 5 or more maps in that array. Thanks for any help. EDIT: Come to think about it, I don't even need to do another query, as I already done the query to populate the drop down menu. I just need to know how to compare the variable to the array now.
  17. Hello, I have two queries which searches for any fixtures your clan (team) is in and then returns some information about the fixtures. Is there any way of combining these results and ordering them by date? $query = "SELECT lc.*, cb.name as clan, cb.clan_id, ladder.name as ladder, ladder.ladder_id FROM ladder_challenges lc LEFT JOIN clans cb ON lc.clan_id_b = cb.clan_id LEFT JOIN ladder_config ladder ON lc.ladder_id = ladder.ladder_id WHERE lc.clan_id_a = $myclanid AND lc.accepted = 0"; $query = "SELECT lc.*, ca.name as clan, ca.clan_id, ladder.name as ladder, ladder.ladder_id FROM ladder_challenges lc LEFT JOIN clans ca ON lc.clan_id_a = ca.clan_id LEFT JOIN ladder_config ladder ON lc.ladder_id = ladder.ladder_id WHERE lc.clan_id_b = $myclanid AND lc.accepted = 0"; Thanks all.
  18. Yeah I added that line, just in case there were errors. I'll add validation to the drop down menu, however wouldn't this be possible with most sites that use drop down menus?
  19. Thanks alot I can use this in other parts of my app too.
  20. Hello, To display a list of challenges I need to access the data in: ladder_challenges -- challenge_id -- ladder_id -- datetime -- clan_id_a (user's clan) -- clan_id_b (opponent clan) clans -- clan_id (linked to clan_id_b) -- name ladder_config -- ladder_id (linked to challenges ladder_id) -- name The WHERE would be: clan_id_a = $myclanid Basically, I need to produce a HTML table with the following headers: Challenge Info (w link contains challenge_id) || Ladder Name (w link contains ladder_id) Date & Time || Clan Name (w contains link clan id). If you guys can come up with the SQL query I can come up with the table. I've only ever done a join using two tables, not three so I'm not sure where to start.
  21. I've fixed the user being able to access the directory and see the list of files, etc but how would I go about fixing the Full path disclosure? Google search just brings up different security reports of scripts but no solutions.
  22. Thanks for the heads up. Rapyd is a plugin library for CI so I'll have to go through it all and see where the problems are as I didn't code that. By the way, I noticed you signed up and created a clan. How did you manage to change then inputted country code from the drop down box to a? How did you manage to get around having a leader_id when creating a clan (hidden input) and a blank datetime? Thanks.
  23. Hello all, I've coded a gaming ladder website using CodeIgnitor and I'd like to let you guys test it out, see what you think, find bugs, security holes, etc. The challenge system hasn't been finished yet so you won't be able to test that. This is mainly for you to find bugs in permissions and current forms and features. Here's the site: http://www.ocwars.com/v2/ There will be a database wipe before I go live so don't worry about damage (try to keep my table structures intact if u manage to screw with my validation ) Test to see if you can access the admin area too: http://www.ocwars.com/v2/index.php/admin/news Thanks for your help!
  24. Hello all, Does anyone know of a script which takes a date (in datetime format) and then displays a different image depending on how many days ago the date was. E.g. if ($date < 7 days ago){ display 7days.gif } elseif ( 7 days < $date < 14 days ago){ display 14days.gif } else { display old.gif } I'd code it myself, but I don't know how to find out if it's more / less than x days. If I could work out how to make it calculate the difference between the dates then I'd be ok. Thanks.
×
×
  • 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.