From 6e3394a6817cfd7554c50c49aee3aec6be8ead34 Mon Sep 17 00:00:00 2001
From: tsf <460834639@qq.com>
Date: Thu, 16 May 2024 18:43:34 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=95=B0=E6=8D=AEDB=E8=BF=9E?=
=?UTF-8?q?=E6=8E=A5=E9=97=AE=E9=A2=98+=E4=B8=80=E4=B8=AA=E8=84=9A?=
=?UTF-8?q?=E6=9C=AC=E6=96=87=E4=BB=B6execlaa.php?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
application/admin/controller/Execlaa.php | 132 +++++++++++++++++++++++
application/app/controller/Base.php | 13 ++-
application/app/controller/Login.php | 20 +++-
application/route.php | 4 +
composer.json | 3 +-
5 files changed, 162 insertions(+), 10 deletions(-)
create mode 100644 application/admin/controller/Execlaa.php
diff --git a/application/admin/controller/Execlaa.php b/application/admin/controller/Execlaa.php
new file mode 100644
index 0000000..5b26a80
--- /dev/null
+++ b/application/admin/controller/Execlaa.php
@@ -0,0 +1,132 @@
+getActiveSheet();
+
+ // dump($spreadsheet);
+ // die;
+ // 获取数据
+ $data = [];
+ $highestRow = $worksheet->getHighestRow(); // 获取最高行数
+ $highestColumn = $worksheet->getHighestColumn(); // 获取最高列
+
+ for ($row = 2; $row <= $highestRow; $row++) { // 假设第一行是标题行
+ $rowData = [];
+ for ($col = 'A'; $col <= $highestColumn; $col++) {
+ $rowData[] = $worksheet->getCell($col . $row)->getValue();
+ }
+ $data[] = $rowData;
+ }
+
+ // 处理数据或返回数据
+ // 例如:输出数据到控制台
+ // foreach ($data as $row) {
+ // var_dump($row);
+ // }
+
+ // 或者你可以将数据保存到数据库或进行其他操作
+
+ // ...
+ // dump($data);
+ // die;
+
+
+
+
+
+
+
+ $picPath = $publicPath . $directory;
+
+ $tupian_arr = [];
+ // 打开目录
+ if ($handle = opendir($picPath)) {
+ // 遍历目录中的文件和子目录
+ while (false !== ($file = readdir($handle))) {
+ // 跳过当前目录和上级目录
+ if ($file != "." && $file != "..") {
+ // 检查文件扩展名是否为图片格式
+ $extension = pathinfo($file, PATHINFO_EXTENSION);
+ $imageExtensions = array('jpg', 'jpeg', 'png', 'gif', 'bmp'); // 添加你需要的图片格式
+
+ if (in_array(strtolower($extension), $imageExtensions)) {
+ // 输出图片文件名或进行其他处理
+ // echo "找到图片文件: " . $file . "
";
+ // 如果你想获取图片完整路径,可以这样做:
+ $fullPath = $picPath . '/' . $file;
+ // echo "图片完整路径: " . $fullPath . "
";
+ // dump($fullPath);
+ // dump($file);
+ // dump(pathinfo($file, PATHINFO_FILENAME));
+ // dump('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
+ $tupian_arr[pathinfo($file, PATHINFO_FILENAME)] = $fullPath;
+ }
+ }
+ }
+ // 关闭目录
+ closedir($handle);
+ } else {
+ echo "无法打开目录 $directory";
+ }
+
+ foreach ($tupian_arr as $key => $value) {
+ for ($i=0; $i < count($data); $i++) {
+ if($data[$i][0] == $key){
+ $this->renameImage($value,$data[$i][4]);
+ break;
+ }
+ }
+ }
+ // dump($tupian_arr);
+ // dump($tupian_arr[1]);
+
+
+ // return json(['status' => 'success', 'data' => $data]); // 假设你想返回JSON响应
+ }
+
+
+ public function renameImage($filename,$newfn)
+ {
+ // 假设这是你的图片文件的当前路径
+ // $filename = './public/uploads/old_name.jpg';
+
+ // 构建新的文件名(确保它与目录中的其他文件不冲突)
+ $newfn = $newfn.'.jpg';
+ $rootPath = $_SERVER['DOCUMENT_ROOT'];
+ $publicPath = rtrim($rootPath, '/');
+ $newImagePath = $publicPath . '/tsf/demo/'.$newfn;
+ // $newImagePath = './public/uploads/' . $newFileName;
+
+ // dump($filename);
+ // dump($newImagePath);
+ // 使用rename()函数重命名文件
+ if (rename($filename, $newImagePath)) {
+ // 重命名成功,可以进行其他操作,如记录日志、返回成功消息等
+ echo '图片重命名成功!';
+ } else {
+ // 重命名失败,处理错误
+ echo '图片重命名失败,请检查路径和权限!';
+ }
+ }
+
+
+}
\ No newline at end of file
diff --git a/application/app/controller/Base.php b/application/app/controller/Base.php
index 453ec20..4d3e11b 100644
--- a/application/app/controller/Base.php
+++ b/application/app/controller/Base.php
@@ -129,14 +129,19 @@ class Base extends Controller{
}
}
- // 绑定设备
- public function base_bind_device(){
-
- }
+
public function msg($code,$msg='',$data=[]){
return json(['code'=>$code,'msg'=>$msg,'data'=>$data]);
}
+
+
+ public function ceshiyong(){
+ $result = Db::query("select * from app_card_data");
+ dump($result);
+ $result2 = Db::table('app_card_data')->select();
+ dump($result2);
+ }
}
\ No newline at end of file
diff --git a/application/app/controller/Login.php b/application/app/controller/Login.php
index d64e7c6..9c27b5d 100644
--- a/application/app/controller/Login.php
+++ b/application/app/controller/Login.php
@@ -18,8 +18,11 @@ class Login extends Base{
################################################################个人资料卡################################################################
// 注册
- public function register_action($data = ['tel'=>18866668888,'password'=>'ceshi','code'=>'123456']){
+ public function register_action($data = ['tel'=>18866668889,'password'=>'ceshi','code'=>'123456']){
+ // dump('123');
+ phpinfo();
+ die;
if(count(input()) > 0){
$data = input();
}
@@ -27,6 +30,7 @@ class Login extends Base{
if(!is_array($verify_result)){
return $this->msg(10001,$verify_result);
}
+ // dump('321');
// 记录
$result = Db::table('app_account_number')->insert($verify_result);
if($result){
@@ -243,7 +247,7 @@ class Login extends Base{
if(!$result){
return $validate->getError();
}
-
+ // dump('3211');
// 判断参数
if(array_key_exists('tel', $data)){
$parameter['tel'] = $data['tel'];
@@ -257,13 +261,18 @@ class Login extends Base{
return '手机/邮箱必须';
}
+ dump($montage_data);
// 检验是否注册过
if($montage_data == 'tel'){
- $inspect_repeat = Db::table('app_account_number')->where(['tel'=>$parameter['tel'],'password'=>$parameter['password']])->count();
+ // $inspect_repeat = Db::table('app_account_number')->where(['tel'=>$parameter['tel'],'password'=>$parameter['password']])->count();
+ $inspect_repeat = Db::query("select count(*) from app_account_number where tel='".$parameter['tel']."'and password='".$parameter['password']);
}else{
$inspect_repeat = Db::table('app_account_number')->where(['email'=>$parameter['email'],'password'=>$parameter['password']])->count();
}
+
+ dump($inspect_repeat);
+ // dump('3212');
if($inspect_repeat){
return '注册失败,账号已存在';
}
@@ -300,8 +309,9 @@ class Login extends Base{
return $str;
}
- public function msg($code,$msg='',$data=[]){
- return json(['code'=>$code,'msg'=>$msg,'data'=>$data]);
+ public function demo_db(){
+ dump('开始测试');
+ $this->ceshiyong();
}
}
\ No newline at end of file
diff --git a/application/route.php b/application/route.php
index bbb4223..b34dd02 100644
--- a/application/route.php
+++ b/application/route.php
@@ -94,6 +94,10 @@ Route::any('/vitalcapacity_data_set', 'app/vitalcapacity/vitalcapacity_data_set'
// // ################################################################其它测试################################################################
Route::any('/generateRandomJumpData', 'app/skip/generateRandomJumpData');
Route::any('/setdb', 'app/skip/setdb');
+Route::any('/readexcel', 'admin/execlaa/readexcel');
+Route::any('/demo_db', 'app/login/demo_db');
+
+
// Route::any('/isNumericArray', 'app/base/isNumericArray');
// 处理404错误 z
diff --git a/composer.json b/composer.json
index 161c830..20f51cc 100644
--- a/composer.json
+++ b/composer.json
@@ -18,7 +18,8 @@
"require": {
"php": ">=5.4.0",
"topthink/framework": "5.0.*",
- "phpmailer/phpmailer": "^6.9"
+ "phpmailer/phpmailer": "^6.9",
+ "phpoffice/phpspreadsheet": "^1.25"
},
"autoload": {
"psr-4": {