进入环境 扫目录。 得到 www.zip ,下载得到 好几个 源码
class.php config.php index.php profile.php register.php update.php
index页面源码:
- require_once('class.php');
- if($_SESSION['username']) {
- header('Location: profile.php');
- exit;
- }
- if($_POST['username'] && $_POST['password']) {
- $username = $_POST['username'];
- $password = $_POST['password'];
-
- if(strlen($username) < 3 or strlen($username) > 16)
- die('Invalid user name');
-
- if(strlen($password) < 3 or strlen($password) > 16)
- die('Invalid password');
-
- if($user->login($username, $password)) {
- $_SESSION['username'] = $username;
- header('Location: profile.php');
- exit;
- }
- else {
- die('Invalid user name or password');
- }
- }
- else {
简单看了下,没有什么问题,只是做了长度的限制,登录进去会跳转到profile.php
注册页面源码:
- require_once('class.php');
- if($_POST['username'] && $_POST['password']) {
- $username = $_POST['username'];
- $password = $_POST['password'];
-
- if(strlen($username) < 3 or strlen($username) > 16)
- die('Invalid user name');
-
- if(strlen($password) < 3 or strlen($password) > 16)
- die('Invalid password');
- if(!$user->is_exists($username)) {
- $user->register($username, $password);
- echo 'Register OK!Please Login';
- }
- else {
- die('User name Already Exists');
- }
- }
- else {
- ?>
也没有什么问题,同样是 检测长度,并且 确定username 存不存在。
update.php
- require_once('class.php');
- if($_SESSION['username'] == null) {
- die('Login First');
- }
- if($_POST['phone'] && $_POST['email'] && $_POST['nickname'] && $_FILES['photo']) {
-
- $username = $_SESSION['username'];
- if(!preg_match('/^\d{11}$/', $_POST['phone']))
- die('Invalid phone');
-
- if(!preg_match('/^[_a-zA-Z0-9]{1,10}@[_a-zA-Z0-9]{1,10}\.[_a-zA-Z0-9]{1,10}$/', $_POST['email']))
- die('Invalid email');
-
- if(preg_match('/[^a-zA-Z0-9_]/', $_POST['nickname']) || strlen($_POST['nickname']) > 10)
- die('Invalid nickname');
-
- $file = $_FILES['photo'];
- if($file['size'] < 5 or $file['size'] > 1000000)
- die('Photo size error');
-
- move_uploaded_file($file['tmp_name'], 'upload/' . md5($file['name']));
- $profile['phone'] = $_POST['phone'];
- $profile['email'] = $_POST['email'];
- $profile['nickname'] = $_POST['nickname'];
- $profile['photo'] = 'upload/' . md5($file['name']);
-
- $user->update_profile($username, serialize($profile));
- echo 'Update Profile Success!Your Profile';
- }
- else {
- ?>
对填写的字符 进行了正则。
profile.php
- require_once('class.php');
- if($_SESSION['username'] == null) {
- die('Login First');
- }
- $username = $_SESSION['username'];
- $profile=$user->show_profile($username);
- if($profile == null) {
- header('Location: update.php');
- }
- else {
- $profile = unserialize($profile);
- $phone = $profile['phone'];
- $email = $profile['email'];
- $nickname = $profile['nickname'];
- $photo = base64_encode(file_get_contents($profile['photo']));
- ?>
- <head>
-
Profile - <link href="static/bootstrap.min.css" rel="stylesheet">
-
-
- "container" style="margin-top:100px">
-
"data:image/gif;base64,$photo; ?>" class="img-memeda " style="width:180px;margin:0px auto;"> -
Hi echo $nickname;?>
-
-
-