Jump to content

wotw

Members
  • Posts

    10
  • Joined

  • Last visited

wotw's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, I have this array which contaisn a php function. When I call upon the array value I would like to use the function (The array value) as normal php. Array ( [item1] => $GLOBALS["class"]->function(1), [item2] => $GLOBALS["class"]->function(4) )
  2. Problem with using is the array is built like this: function files(){ $file_array = $this->files; $files = array(); foreach($file_array as $value){ $files[] = $value['files']; } return $files; } That funcxtion is from a class file. That functiopn returns the array posted above. How can I make all the valueas into one array mate?
  3. Hey, Could someone help me move these arrays into one array please? i.e move them up one level. Array ( [0] => Array ( [0] => content_first ) [1] => Array ( [0] => content_again [1] => content ) } Thanks.
  4. I know all this. I used a switch because I normnally use a switch to do a password forgotten case and register. Here is a quick secure class I wrote which you can use to secure your password: <?php class secure{ ## GET A RANDOM SALT function secure_random_salt(){ $randtext = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'; $varlen = rand(5, 20); $randtextlen = strlen($randtext); $salt = ''; for($i = 0; $i < $varlen; $i++){ $salt .= substr($randtext,rand(1,$randtextlen),1); } return $salt; } ## ENCODES PASSWORD function secure_encode_password($password, $salt = ''){ if($salt == ''){ $salt = $this->secure_random_salt(); } return md5($password.$salt).':'.$salt; } ## CHECK PASSWORDS MATCHES function secure_check_password($password, $db_password){ $explode = explode(':', $db_password); if(isset($explode[1])){ if($this->secure_encode_password($password, $explode[1]) == $db_password){ return true; }else{ return false; } }else{ return false; } } } $secure = new secure; ?> Simply including the class file and do this to create your password string. // There is more to this class but I have cut it down. You could create a new function which will secure the posted values like the guys mention above. $insert_password = $secure->secure_encode_password($password); // Password to insert into the db. // And to check if the password is the same when they post it: // $db_password is the actual password from the database. // $password is the password posted from the login form. if($secure->secure_check_password($password, $db_password)){ // Log the user in. $_SESSION etc.. }
  5. But doing a software update this way is the very best way to do it?
  6. Christian, Thanks man. I never knew you could do it like that with a switch statement. I always thought it read everything at once doing switches like that. Thats awesome. Thanks
  7. Say for instance. I release version 3.0.4 But the user is still on version 1.0.2. It needs to update them all in order.
  8. Can you do me a little sample? I am kind of lost at what you mean mate. Thanks
  9. Hey, I have written you something that you could incorporate into your script. I basically wrote this with my eyes closed and I haven't tested it. If you get issues let me know and I can help. You need to add a hidden input into your login form and call it: login & give it a value of 1. You would also need to implement your password encoding where it says: Do your password encoding. <?php $case = isset($_POST['login']) ? 'login' : false; $error = false; switch($case){ case'login': $username = isset($_POST['username']) ? mysqli_real_escape_string($mysqli, $_POST['username']) : false; $password = isset($_POST['password']) ? mysqli_real_escape_string($mysqli, $_POST['password']) : false; if($username && $password){ // Do your password encoding here. $password = ? $query = mysqli_query($mysqli, "SELECT * FROM Persons WHERE Username = '$username' AND password = '$password'"); $numrows = mysqli_num_rows($query); if($numrows > 0){ $row = mysqli_fetch_assoc($query); // Set sessions $_SESSION['login'] = true; $_SESSION['ID'] = $row['PlayerID']; $_SESSION['username'] = $row['Username']; $_SESSION['email'] = $row['Email']; // Redirect header("Location: loggedin.php"); }else{ $error = true; } }else{ $error = true; } break; } if($error){ echo '<font color=red>Authentication failed</font>'; } echo 'Display login form here'; ?>
  10. Hey guys, I registered on another forum hot.... they never activated my account or help me so here it goes. I hope you guys are friendly I am basically trying to return an array with all the versions that the current software hasn't updated too. (I am making a software update script) I have built everything else including an API etc.. I have 12 years php knowlegde but this is bugging me and I have never come across this before. So I have an array: private $current_versions = array( '1.0.0', '1.0.1', '1.0.2', '1.1.0', '1.1.1', '1.1.2' ); This array is all of the versions for the software. I have two other variables: $current_version = '1.0.2'; $new_version = '1.1.2'; I am basically trying to get the difference. The current version the software is running is: 1.0.2 and the current actual version of the software is: 1.1.2. I need to return an array with just the versions the software is missing, so that I can run the update based on them versions only; in order. Thanks for your help and I will be taking part in this forum full time
×
×
  • 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.