$id = getgpc('aim_id') ?: ""; $dir = getgpc('dir') ?: ""; $new_date = getgpc('new_date') ?: ""; if (!$id || !$dir) { $display = 0; $getMsgByTid = "url不合法"; } /*操作*/ /*1 wap*/ $array = array('news_id' => $id, 'date_new' => $new_date); $_ENV['wap_change_record']->add_one($array); $getMsgByTid = "WAP更新成功!"; /*2 PC 修改文件*/ chmod($dir, 777); $file_content = file_get_contents($dir); if ($file_content) { $date_str = "<SPAN>".date("Y年m月d日",strtotime($new_date))."</SPAN>"; //$patten = "/^d{4}[-](0?[1-9]|1[012])[-](0?[1-9]|[12][0-9]|3[01])(s+(0?[0-9]|1[0-9]|2[0-3]):(0?[0-9]|[1-5][0-9]):(0?[0-9]|[1-5][0-9]))?$/"; $patten = "/<SPAN>d{4}年(0?[1-9]|1[012])月(0?[1-9]|[12][0-9]|3[01])日</SPAN>/"; $match = preg_match($patten,$file_content); $update_str = preg_replace($patten, $date_str, $file_content); $re1 = file_put_contents($dir, $update_str); // $getMsgByTid .= "换取文字:" . $update_str; if ($re1) { $getMsgByTid .= "PC更新成功!"; } else { $getMsgByTid .= "PC更新失败!"; } } else { $getMsgByTid .= "PC未读取到文件:" . $dir; }