/[LeafOK_CVS]/fenglin/bbs/user_service_update_pref.php
ViewVC logotype

Diff of /fenglin/bbs/user_service_update_pref.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.1 by sysadm, Wed Apr 23 05:56:10 2025 UTC Revision 1.6 by sysadm, Thu Nov 6 03:19:46 2025 UTC
# Line 1  Line 1 
1  <?php  <?php
2          require_once "../lib/db_open.inc.php";          require_once "../lib/db_open.inc.php";
3            require_once "../lib/lml.inc.php";
4          require_once "../lib/str_process.inc.php";          require_once "../lib/str_process.inc.php";
5          require_once "./session_init.inc.php";          require_once "./session_init.inc.php";
6          require_once "./check_sub.inc.php";          require_once "./check_sub.inc.php";
7    
8          force_login();          force_login();
9    
10            function check_input_data(string $input_str, string $id_str, array & $result_set, int $max_line_cnt) : bool
11            {
12                    $r_input_str = check_badwords($input_str, "****");
13                    if ($input_str != $r_input_str)
14                    {
15                            $result_set["return"]["code"] = -1;
16                            array_push($result_set["return"]["errorFields"], array(
17                                    "id" => $id_str,
18                                    "errMsg" => "非法内容已被过滤",
19                                    "updateValue" => $r_input_str,
20                            ));
21    
22                            return false;
23                    }
24    
25                    $r_input_str = LML($input_str, 80);
26                    if (split_line($r_input_str, "", 256, $max_line_cnt) != $r_input_str)
27                    {
28                            $result_set["return"]["code"] = -1;
29                            array_push($result_set["return"]["errorFields"], array(
30                                    "id" => $id_str,
31                                    "errMsg" => "内容超过长度限制",
32                                    "updateValue" => $input_str,
33                            ));
34    
35                            return false;
36                    }
37    
38                    return true;
39            }
40    
41          $user_tz = (isset($_POST["user_tz"]) ? $_POST["user_tz"] : "");          $user_tz = (isset($_POST["user_tz"]) ? $_POST["user_tz"] : "");
42          $photo = (isset($_POST["photo"]) ? intval($_POST["photo"]) : 0);          $photo = (isset($_POST["photo"]) ? intval($_POST["photo"]) : 0);
43          $introduction = str_replace("\r\n", "\n", (isset($_POST["introduction"]) ? $_POST["introduction"] : ""));          $introduction = str_replace("\r\n", "\n", (isset($_POST["introduction"]) ? $_POST["introduction"] : ""));
# Line 34  Line 66 
66                  ));                  ));
67          }          }
68    
69          $r_introduction = check_badwords(split_line($introduction, "", 80, 10), "****");          check_input_data($introduction, "introduction", $result_set, 10);
         if ($introduction != $r_introduction)  
         {  
                 $result_set["return"]["code"] = -1;  
                 array_push($result_set["return"]["errorFields"], array(  
                         "id" => "introduction",  
                         "errMsg" => "不符合要求",  
                         "updateValue" => $r_introduction,  
                 ));  
         }  
70    
71          $r_sign_1 = check_badwords(split_line($sign_1, "", 80, 10), "****");          check_input_data($sign_1, "sign_1", $result_set, 10);
72          if ($sign_1 != $r_sign_1)          check_input_data($sign_2, "sign_2", $result_set, 10);
73          {          check_input_data($sign_3, "sign_3", $result_set, 10);
                 $result_set["return"]["code"] = -1;  
                 array_push($result_set["return"]["errorFields"], array(  
                         "id" => "sign_1",  
                         "errMsg" => "不符合要求",  
                         "updateValue" => $r_sign_1,  
                 ));  
         }  
   
         $r_sign_2 = check_badwords(split_line($sign_2, "", 80, 10), "****");  
         if ($sign_2 != $r_sign_2)  
         {  
                 $result_set["return"]["code"] = -1;  
                 array_push($result_set["return"]["errorFields"], array(  
                         "id" => "sign_2",  
                         "errMsg" => "不符合要求",  
                         "updateValue" => $r_sign_2,  
                 ));  
         }  
   
         $r_sign_3 = check_badwords(split_line($sign_3, "", 80, 10), "****");  
         if ($sign_3 != $r_sign_3)  
         {  
                 $result_set["return"]["code"] = -1;  
                 array_push($result_set["return"]["errorFields"], array(  
                         "id" => "sign_3",  
                         "errMsg" => "不符合要求",  
                         "updateValue" => $r_sign_3,  
                 ));  
         }  
74    
75          if ($result_set["return"]["code"] != 0)          if ($result_set["return"]["code"] != 0)
76          {          {
# Line 108  Line 102 
102                                  "id" => "photo_file",                                  "id" => "photo_file",
103                                  "errMsg" => "上传文件错误",                                  "errMsg" => "上传文件错误",
104                          ));                          ));
105            
106                          mysqli_close($db_conn);                          mysqli_close($db_conn);
107                          exit(json_encode($result_set));                          exit(json_encode($result_set));
108                  }                  }
# Line 128  Line 122 
122                                  "id" => "photo_file",                                  "id" => "photo_file",
123                                  "errMsg" => "文件大小超过限制",                                  "errMsg" => "文件大小超过限制",
124                          ));                          ));
125                    
126                          mysqli_close($db_conn);                          mysqli_close($db_conn);
127                          exit(json_encode($result_set));                          exit(json_encode($result_set));
128                  }                  }
129    
130                  $ext = strtolower(substr($filename, (strrpos($filename, ".") ? strrpos($filename, ".") + 1 : 0)));                  $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
131                  switch ($ext)                  switch ($ext)
132                  {                  {
133                          case "bmp":                          case "bmp":
# Line 150  Line 144 
144                                          "id" => "photo_file",                                          "id" => "photo_file",
145                                          "errMsg" => "不支持的文件扩展名",                                          "errMsg" => "不支持的文件扩展名",
146                                  ));                                  ));
147                                            
148                                  mysqli_close($db_conn);                                  mysqli_close($db_conn);
149                                  exit(json_encode($result_set));                                  exit(json_encode($result_set));
150                  }                  }
151            
152                  $finfo = new finfo(FILEINFO_MIME_TYPE);                  $finfo = new finfo(FILEINFO_MIME_TYPE);
153                  $mime_type = $finfo->file($_FILES['photo_file']['tmp_name'][$i]);                  $mime_type = $finfo->file($_FILES['photo_file']['tmp_name'][$i]);
154                  $real_ext = array_search($mime_type, array(                  $real_ext = array_search($mime_type, array(
# Line 164  Line 158 
158                                  'gif' => 'image/gif',                                  'gif' => 'image/gif',
159                                  'tif' => 'image/tiff',                                  'tif' => 'image/tiff',
160                                  ), true);                                  ), true);
161                            
162                  if ($real_ext === false)                  if ($real_ext === false)
163                  {                  {
164                          $result_set["return"]["code"] = -1;                          $result_set["return"]["code"] = -1;
# Line 172  Line 166 
166                                  "id" => "photo_file",                                  "id" => "photo_file",
167                                  "errMsg" => "不支持的文件格式",                                  "errMsg" => "不支持的文件格式",
168                          ));                          ));
169                                    
170                          mysqli_close($db_conn);                          mysqli_close($db_conn);
171                          exit(json_encode($result_set));                          exit(json_encode($result_set));
172                  }                  }
# Line 184  Line 178 
178                                  "id" => "photo_file",                                  "id" => "photo_file",
179                                  "errMsg" => "分析文件出错",                                  "errMsg" => "分析文件出错",
180                          ));                          ));
181                                    
182                          mysqli_close($db_conn);                          mysqli_close($db_conn);
183                          exit(json_encode($result_set));                          exit(json_encode($result_set));
184                  }                  }
185                            
186                  if ($size[0] > 120 || $size[1] > 120)                  if ($size[0] > 120 || $size[1] > 120)
187                  {                  {
188                          $result_set["return"]["code"] = -1;                          $result_set["return"]["code"] = -1;
# Line 196  Line 190 
190                                  "id" => "photo_file",                                  "id" => "photo_file",
191                                  "errMsg" => "图片尺寸超过限制",                                  "errMsg" => "图片尺寸超过限制",
192                          ));                          ));
193                                    
194                          mysqli_close($db_conn);                          mysqli_close($db_conn);
195                          exit(json_encode($result_set));                          exit(json_encode($result_set));
196                  }                  }
# Line 207  Line 201 
201                  {                  {
202                          $result_set["return"]["code"] = -2;                          $result_set["return"]["code"] = -2;
203                          $result_set["return"]["message"] = "Copy file error";                          $result_set["return"]["message"] = "Copy file error";
204            
205                          mysqli_close($db_conn);                          mysqli_close($db_conn);
206                          exit(json_encode($result_set));                          exit(json_encode($result_set));
207                  }                  }
# Line 239  Line 233 
233    
234          mysqli_close($db_conn);          mysqli_close($db_conn);
235          exit(json_encode($result_set));          exit(json_encode($result_set));
 ?>  


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1