From 5f3d1d6adb59bf1606f90b2104df7bff7e5c58ef Mon Sep 17 00:00:00 2001 From: zyx0814 Date: Fri, 3 May 2024 20:51:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install/update.php | 2 +- misc/doaitask.php | 25 +++++++++++++++++++++---- misc/exportfile.php | 6 +++--- misc/exportfilecheck.php | 7 +++---- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/install/update.php b/install/update.php index e36202d..60ec192 100644 --- a/install/update.php +++ b/install/update.php @@ -415,7 +415,7 @@ if ($_GET['step'] == 'start') { ]; foreach ($cornarr as $v) { - if (DB::result_first("select cronid from %t where filename = %s", array('cron', $v['filename']))) { + if (!DB::result_first("select cronid from %t where filename = %s", array('cron', $v['filename']))) { DB::insert('cron', $v); } } diff --git a/misc/doaitask.php b/misc/doaitask.php index 4aa83e8..e164dd0 100644 --- a/misc/doaitask.php +++ b/misc/doaitask.php @@ -22,11 +22,15 @@ if ($locked) { } $limit = 100; foreach (DB::fetch_all("select * from %t where 1 limit 0,$limit ", array('ai_task')) as $v) { + if ($v['aikey'] == 'aiXh::chatImage') { require_once DZZ_ROOT . './dzz/aiXhimage/class/xhChat.php'; $tplid = $v['tplid']; $promptdata = C::t('#aiXhimage#ai_xhimageprompt')->fetch($tplid); - if (!$promptdata) continue; + if (!$promptdata){ + C::t('ai_task')->delete($v['id']); + continue; + } $getType = $promptdata['cate']; if ($promptdata['cate'] == 1) { $question = $promptdata['prompt'] . '。返回结果的格式为“标签1,标签2,标签3”,其中标签之间使用逗号分割。'; @@ -40,6 +44,7 @@ foreach (DB::fetch_all("select * from %t where 1 limit 0,$limit ", array('ai_tas C::t('ai_task')->delete($v['id']); continue; } + $imgurl = FALSE; $thumbdata = DB::fetch_first("select * from %t where rid =%s", array('thumb_record', $rid)); if ($thumbdata['sstatus']) { @@ -56,6 +61,7 @@ foreach (DB::fetch_all("select * from %t where 1 limit 0,$limit ", array('ai_tas if(!$metadata['aid']) $metadata['aid'] = 0; $setarr = ['aid' => $metadata['aid'], 'rid' => $rid, 'gettype' => $getType, 'tplid' => $tplid, 'aikey' => $v['aikey']]; $cachedata = C::t('ai_imageparse')->insertData($setarr); + if ($cachedata) { if ($cachedata['isget'] && $cachedata['data']) { $content = $cachedata['data']; @@ -69,8 +75,14 @@ foreach (DB::fetch_all("select * from %t where 1 limit 0,$limit ", array('ai_tas $params['processname'] = $return; } $chatclinet = new xhChat(); + $aireturn = $chatclinet->getApiData('aiXh::chatImage', $params); - if ($aireturn['error_msg']) return ['error' => $aireturn['error_msg']]; + + if ($aireturn['error_msg']){ + C::t('ai_imageparse')->update($cachedata['id'], ['isget' => 1, 'data' => '']); + C::t('ai_task')->delete($v['id']); + continue; + } if ($aireturn['result']) { if ($aireturn['totaltoken']) { $tokendatas = [ @@ -120,14 +132,19 @@ foreach (DB::fetch_all("select * from %t where 1 limit 0,$limit ", array('ai_tas C::t('ai_task')->delete($v['id']); } elseif ($getType == 2) { $desc = getstr($content); - C::t('pichome_resources_attr')->update_by_rids($metadata['appid'], $rid, ['desc' => $desc]); + if($desc)C::t('pichome_resources_attr')->update_by_rids($metadata['appid'], $rid, ['desc' => $desc]); C::t('ai_task')->delete($v['id']); } elseif ($getType == 0) { + $name = trim(name_filter($content)); $name = str_replace([',',',','.','。'],'',$name); $name = getstr($name,30); - C::t('pichome_resources')->update_by_rids($metadata['appid'], $rid, ['name' => $name.'.'.$metadata['ext']]); + if($content){ + C::t('pichome_resources')->update_by_rids($metadata['appid'], $rid, ['name' => $name.'.'.$metadata['ext']]); + } C::t('ai_task')->delete($v['id']); + + } } diff --git a/misc/exportfile.php b/misc/exportfile.php index 20c85c0..0f3bba1 100644 --- a/misc/exportfile.php +++ b/misc/exportfile.php @@ -43,7 +43,7 @@ try{ $return = $eagleexport->execExport($force); }catch (Exception $e){ - C::t('pichome_vapp')->update($appid,['state'=>0]); + // C::t('pichome_vapp')->update($appid,['state'=>0]); runlog('eagleexporterror',$appid.$e->getMessage()); dzz_process::unlock($processname); } @@ -57,7 +57,7 @@ try{ $return = $localexport->execExport($force); }catch (Exception $e){ - C::t('pichome_vapp')->update($appid,['state'=>0]); + //C::t('pichome_vapp')->update($appid,['state'=>0]); runlog('localexporterror',$appid.$e->getMessage()); dzz_process::unlock($processname); } @@ -67,7 +67,7 @@ try{ $return = $billfishxport->execExport($force); }catch (Exception $e){ - C::t('pichome_vapp')->update($appid,['state'=>0]); + // C::t('pichome_vapp')->update($appid,['state'=>0]); runlog('billfishexporterror',$appid.$e->getMessage()); dzz_process::unlock($processname); } diff --git a/misc/exportfilecheck.php b/misc/exportfilecheck.php index c265032..dbfcdd8 100644 --- a/misc/exportfilecheck.php +++ b/misc/exportfilecheck.php @@ -24,12 +24,11 @@ if (!$data) exit(json_encode(array('error' => 'no data'))); if ($data['state'] != 3 || $data['isdelete'] > 0) exit(json_encode(array('error' => 'is deleted or state is not allow'))); if ($data['type'] == 0) { include_once DZZ_ROOT.'dzz'.BS.'eagle'.BS.'class'.BS.'class_eagleexport.php'; - //include_once dzz_libfile('eagleexport'); $eagleexport = new eagleexport($data); try{ $return = $eagleexport->execCheckFile(); }catch (Exception $e){ - C::t('pichome_vapp')->update($appid,['state'=>0]); + //C::t('pichome_vapp')->update($appid,['state'=>0]); runlog('eagleexporterror', $appid . $e->getMessage()); dzz_process::unlock($processname); } @@ -41,7 +40,7 @@ if ($data['type'] == 0) { try{ $return = $localexport->execCheckFile(); }catch (Exception $e){ - C::t('pichome_vapp')->update($appid,['state'=>0]); + //C::t('pichome_vapp')->update($appid,['state'=>0]); runlog('localexporterror', $appid . $e->getMessage()); dzz_process::unlock($processname); } @@ -52,7 +51,7 @@ if ($data['type'] == 0) { try{ $return = $billfishxport->execCheckFile(); }catch (Exception $e){ - C::t('pichome_vapp')->update($appid,['state'=>0]); + //C::t('pichome_vapp')->update($appid,['state'=>0]); runlog('billfishexporterror', $appid . $e->getMessage()); dzz_process::unlock($processname); }