/[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.2 by sysadm, Sun Apr 27 02:35:47 2025 UTC Revision 1.7 by sysadm, Thu Nov 6 12:39:59 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                    $bw_count = 0;
13                    $r_input_str = check_badwords($input_str, "****", $bw_count);
14                    if ($bw_count > 0)
15                    {
16                            $result_set["return"]["code"] = -1;
17                            array_push($result_set["return"]["errorFields"], array(
18                                    "id" => $id_str,
19                                    "errMsg" => "非法内容已被过滤",
20                                    "updateValue" => $r_input_str,
21                            ));
22    
23                            return false;
24                    }
25    
26                    $r_input_str = LML($input_str, 80);
27                    if (split_line($r_input_str, "", 256, $max_line_cnt) != $r_input_str)
28                    {
29                            $result_set["return"]["code"] = -1;
30                            array_push($result_set["return"]["errorFields"], array(
31                                    "id" => $id_str,
32                                    "errMsg" => "内容超过长度限制",
33                                    "updateValue" => $input_str,
34                            ));
35    
36                            return false;
37                    }
38    
39                    return true;
40            }
41    
42          $user_tz = (isset($_POST["user_tz"]) ? $_POST["user_tz"] : "");          $user_tz = (isset($_POST["user_tz"]) ? $_POST["user_tz"] : "");
43          $photo = (isset($_POST["photo"]) ? intval($_POST["photo"]) : 0);          $photo = (isset($_POST["photo"]) ? intval($_POST["photo"]) : 0);
44          $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 67 
67                  ));                  ));
68          }          }
69    
70          $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,  
                 ));  
         }  
71    
72          $r_sign_1 = check_badwords(split_line($sign_1, "", 80, 10), "****");          check_input_data($sign_1, "sign_1", $result_set, 10);
73          if ($sign_1 != $r_sign_1)          check_input_data($sign_2, "sign_2", $result_set, 10);
74          {          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,  
                 ));  
         }  
75    
76          if ($result_set["return"]["code"] != 0)          if ($result_set["return"]["code"] != 0)
77          {          {
# Line 108  Line 103 
103                                  "id" => "photo_file",                                  "id" => "photo_file",
104                                  "errMsg" => "上传文件错误",                                  "errMsg" => "上传文件错误",
105                          ));                          ));
106            
107                          mysqli_close($db_conn);                          mysqli_close($db_conn);
108                          exit(json_encode($result_set));                          exit(json_encode($result_set));
109                  }                  }
# Line 128  Line 123 
123                                  "id" => "photo_file",                                  "id" => "photo_file",
124                                  "errMsg" => "文件大小超过限制",                                  "errMsg" => "文件大小超过限制",
125                          ));                          ));
126                    
127                          mysqli_close($db_conn);                          mysqli_close($db_conn);
128                          exit(json_encode($result_set));                          exit(json_encode($result_set));
129                  }                  }
# Line 150  Line 145 
145                                          "id" => "photo_file",                                          "id" => "photo_file",
146                                          "errMsg" => "不支持的文件扩展名",                                          "errMsg" => "不支持的文件扩展名",
147                                  ));                                  ));
148                                            
149                                  mysqli_close($db_conn);                                  mysqli_close($db_conn);
150                                  exit(json_encode($result_set));                                  exit(json_encode($result_set));
151                  }                  }
152            
153                  $finfo = new finfo(FILEINFO_MIME_TYPE);                  $finfo = new finfo(FILEINFO_MIME_TYPE);
154                  $mime_type = $finfo->file($_FILES['photo_file']['tmp_name'][$i]);                  $mime_type = $finfo->file($_FILES['photo_file']['tmp_name'][$i]);
155                  $real_ext = array_search($mime_type, array(                  $real_ext = array_search($mime_type, array(
# Line 164  Line 159 
159                                  'gif' => 'image/gif',                                  'gif' => 'image/gif',
160                                  'tif' => 'image/tiff',                                  'tif' => 'image/tiff',
161                                  ), true);                                  ), true);
162                            
163                  if ($real_ext === false)                  if ($real_ext === false)
164                  {                  {
165                          $result_set["return"]["code"] = -1;                          $result_set["return"]["code"] = -1;
# Line 172  Line 167 
167                                  "id" => "photo_file",                                  "id" => "photo_file",
168                                  "errMsg" => "不支持的文件格式",                                  "errMsg" => "不支持的文件格式",
169                          ));                          ));
170                                    
171                          mysqli_close($db_conn);                          mysqli_close($db_conn);
172                          exit(json_encode($result_set));                          exit(json_encode($result_set));
173                  }                  }
# Line 184  Line 179 
179                                  "id" => "photo_file",                                  "id" => "photo_file",
180                                  "errMsg" => "分析文件出错",                                  "errMsg" => "分析文件出错",
181                          ));                          ));
182                                    
183                          mysqli_close($db_conn);                          mysqli_close($db_conn);
184                          exit(json_encode($result_set));                          exit(json_encode($result_set));
185                  }                  }
186                            
187                  if ($size[0] > 120 || $size[1] > 120)                  if ($size[0] > 120 || $size[1] > 120)
188                  {                  {
189                          $result_set["return"]["code"] = -1;                          $result_set["return"]["code"] = -1;
# Line 196  Line 191 
191                                  "id" => "photo_file",                                  "id" => "photo_file",
192                                  "errMsg" => "图片尺寸超过限制",                                  "errMsg" => "图片尺寸超过限制",
193                          ));                          ));
194                                    
195                          mysqli_close($db_conn);                          mysqli_close($db_conn);
196                          exit(json_encode($result_set));                          exit(json_encode($result_set));
197                  }                  }
# Line 207  Line 202 
202                  {                  {
203                          $result_set["return"]["code"] = -2;                          $result_set["return"]["code"] = -2;
204                          $result_set["return"]["message"] = "Copy file error";                          $result_set["return"]["message"] = "Copy file error";
205            
206                          mysqli_close($db_conn);                          mysqli_close($db_conn);
207                          exit(json_encode($result_set));                          exit(json_encode($result_set));
208                  }                  }
# Line 239  Line 234 
234    
235          mysqli_close($db_conn);          mysqli_close($db_conn);
236          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