util.php 503 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. function check_login() {
  3. if (isset($_SESSION['login']) && $_SESSION ['login'] === true) {
  4. return true;
  5. }
  6. return false;
  7. }
  8. function read_config() {
  9. return parse_ini_file('config/config.ini');
  10. }
  11. function check_password_quality($pwd) {
  12. if (!isset($pwd)||strlen($pwd)<4) {
  13. return false;
  14. }
  15. return true;
  16. }
  17. function check_username($username) {
  18. if (!isset($username)||strlen($username)>20 || strlen($username)<3) {
  19. return false;
  20. }
  21. return preg_match('/^[a-zA-Z0-9]+$/', $username);
  22. }
  23. ?>