public function getSalt() { $password = $this->password; $token = new Token(); $hash = $token->generatePassword(15); $this->hash = $hash; $salt = md5($password . $hash); return $salt; }
public function getCookie(Slim\Slim &$app) { if (empty($app->getCookie('username'))) { //setting cokkie if the user doesn't have it $generateToken = new Token(); $cookieKey = md5($generateToken->generatePassword(8)); $app->setCookie('username', $cookieKey, time() + 86400 * 4); } $cookie = $app->getCookie('username'); return $cookie; }
public function postFile(Token &$generateToken, $postarr = array(), $postFile = array()) { $postarr[] = $_POST; $postFile[] = $_FILES; $_FILES['img']['tmp_name']; $target_dir = "uploads/"; $target_file = $target_dir . basename($_FILES["img"]["name"]); $filename = trim($_FILES['img']['name']); move_uploaded_file($_FILES["img"]["tmp_name"], $target_file); $filesize = filesize('uploads/' . $filename); //$generateToken = new Token(); //setting unique token $token = $generateToken->generatePassword(8); if (isset($_POST['public'])) { $public = "1"; } else { $public = "0"; } $terminate = date('Y-m-d H:i:s', time() + 3600 * 24); $array = array('filename' => $filename, 'filesize' => $filesize, 'token' => $token, 'public' => $public, 'terminate' => $terminate); return $array; }