Jump to content

deanlearner

Members
  • Posts

    21
  • Joined

  • Last visited

    Never

Everything posted by deanlearner

  1. I've just thought that, I will obviously need to run rsync the other way on the second server and am worried about if overlapping rsyncs could some how really bork things up
  2. I have live master-master replication running on a mysql database (currently only really used as master-slave, but for the following to work I've configured it as master-master). Users can upload files to the system, the file is stored in a documents directory and an entry is added to the database pointing to this file. NOW, I want this uploaded file to be replicated in the required place on the other system as well and even if the connection isnt available for a while, it will perform the replication when it can. Can such replication be set up in a live fashion? I've not given it too much thought just yet, but I am thinking of doing an rsync every X minutes and picking up the changes as required. Anyone have any experience with this? Thanks
  3. at the start of the PHP script in question set_time_limit(0); Will allow the script to take as long as it needs. http://php.net/manual/en/function.set-time-limit.php If you're more sure of how long you expect the file to take, it might be worth setting a time limit that will allow it, just in case.
  4. woops, unless of course you do "INSERT INTO `table (`".implode('`,`',$name_array)."`) VALUES ('".implode("','",$value_array)."')"; which is nice Oops and yeah the back-ticks in the value array was an error on my part
  5. I've not even considered implode before, but looking at it, unless im mistaken you will need to include the ` marks in the field name as implode cannot add them as required.
  6. $name_array = an array of field names $value_array = an array of values ( in your case $fldNames) <?php $name_array = array('field_1','field_2','field_3','field_4'); $value_array = array('value_1','value_2','value_3','value_4'); $sql = "INSERT INTO `table` ("; foreach($name_array as $name){ $sql .= "`".$name."`, "; } $sql = substr($sql,0,-1).") VALUES ("; foreach($value_array as $value){ $sql .= "`".$name."`, "; } $sql = substr($sql,0,-1).")"; ?>
  7. Almost $fields = array(0 => 'straight', 1 => 'bisexual', 2 => 'lesbian/gay', 3 => 'asexual', 4 => 'pansexual'); foreach($fields as $num => $name){ if(in_array($name,$profile->orien_status)){$selected = 'selected';}else{$selected = '';} echo '<option value="'.$name.'" '.$selected.' /> '.ucfirst($name).' </option>'; } should be $fields = array(0 => 'straight', 1 => 'bisexual', 2 => 'lesbian/gay', 3 => 'asexual', 4 => 'pansexual'); foreach($fields as $num => $name){ if($name==$profile->orien_status){$selected = 'selected';}else{$selected = '';} echo '<option value="'.$name.'" '.$selected.' /> '.ucfirst($name).' </option>'; }
  8. Ooo nice, I didnt realise strrpos returned the last instance, do what Ken2k7 said.
  9. for each input line... $tmp = explode('-',$input); $output = str_replace('-'.$tmp[count($tmp)-1],'',$input);
  10. the number 0 == false : returns true the number 0 === false : returns false because the data types are different the string '1' == true : returns true the string '1' === true : returns false because the data types are different
  11. Woops yeah, sorry i quickly rushed it together! You can do what you're after using the same logic I used in the previous example, but change the field array to straight, bisexual, etc, etc and change the echo row as required as well
  12. Maybe you could check the time between the last player action and the current action and calculate based on that? Like... 15:50pm - enter hospital 15:55pm - did something else (and run function add_health($player_id,$last_action_time,$next_action_time) ) the add_health() function could then work out the duration between the two times and add health as required.
  13. Im not entirely sure if im understanding but... would the following work? $fields = (0 => 'men', 1=> 'women', 2=> 'none', 3=> 'other'); $proin = explode(', ', $profile->interested_in); foreach($fields as $num => $name){ if(in_array($name,$proin)){$checked = 'checked';}else{$checked = '';} echo '<input type="checkbox" name="intin[]" value="'.$name.'" '.$checked.' /> '.ucfirst($name); }
  14. you can use \" to print a " even if it is between " ... " echo "quote \"within\" a quote"; will show quote "within" a quote The same logic goes with using \' between ' ... '
  15. Thanks for the reply Salathe, based on the fact you think this is a small issue, I'll stick with my current system for now but might post again regarding finding an alternative solution at a later date, but hopefully it won't come need to come to that! Thanks again
  16. I don't think you should worry about record numbers, honestly. I don't know the details but a paragraph of text in a database is worth 1000's of records that store three numbers.
  17. I've never really worked with any forum software, but I imagine you would need another table (lets call it viewed_topic) that stores the topic id and the user id so each time a user accesses a topic, you add to the viewed_topic table a record for the user_id and the topic_id and make reference to that.
  18. name your submit buttons <input type="submit" name="submit_form" value="submit1"/> <input type="submit" name="submit_form" value="submit2"/> <input type="submit" name="submit_form" value="submit3"/> and in the code that checks if a form submitted if(isset($_POST['submit_form'])){ switch($_POST['submit_form']){ case "submit1": // Do something when submit button 1 is pressed break; case "submit2": // Do something when submit button 2 is pressed break; case "submit3": // Do something when submit button 3 is pressed break; } }
  19. If you want the site to know if a user has accessed a topic over multiple visits, you will need to store this information in a database. If indeed it is only for the current session (that is, a single visit to the site) you can store it in a session and I'd do something like this... Each time a user accesses a topic $_SESSION['viewed'][$TOPIC_ID]=1; And on the list of topics, for each topic check... if(isset($_SESSION['viewed'][$TOPIC_ID])){ // This topic has been viewed }else{ // This topic has not been viewed }
  20. Sorry, no help but, is the game purely PHP based, like via the CLI? Or is it presented via a web interface or something?
  21. Hi everyone, I have made a system that uses XML as a basis for directory permissions <?xml version="1.0" encoding="ISO-8859-1"?> <permissions group_a="1" group_b="1"> <folder1 group_b="0" /> <folder2> <page1.php group_a="0" /> <page2.php group_b="0" /> </folder2> </permissions> Basically, the system looks for the most relevant permission possible, so if a user of group_a requests /folder2/page1.php access will be denied because access is set to "0". If a user of group_b requests /folder2/page1.php access will be granted because the most relevant permission is set in the head xml tag. This file will be accessed via the system with every request made by a user so I am wondering if it's worth it, or possible to store it in memory? I know multiple files will be accessed with every request, but as I know this one will always occur I am wondering about loading it into memory. Also, while hoping people are actually able to understand the security scheme I've used above, would anyone suggest an alternative? Would storing permissions for each possible request URI (ignoring $_GET stuff) in a database be a better solution? There will be about 20-30 users of this system at any one time (so again, maybe I am threating about something thats not important at all). Thanks again.
×
×
  • 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.