This commit is contained in:
wangjinlei
2024-08-12 15:51:30 +08:00
parent 1f7220f36e
commit 0a6126543b
6 changed files with 73 additions and 53 deletions

View File

@@ -275,6 +275,30 @@ die;
}
public function myPush(){
// phpinfo();die;
// $data = $this->request->post();
// $rule = new Validate([
// "email"=>"require",
// "title"=>"require",
// "content"=>"require"
// ]);
// if(!$rule->check($data)){
// return jsonError($rule->getError());
// }
$data['email'] = "751475802@qq.com";
$data['title'] = "test title";
$data['content'] = "content";
echo sendMyEmail($data['email'],$data['title'],$data['content']);
}
public function lsPushEmail()
{
// $journal_info = $this->journal_obj->where("journal_id", 4)->find();

View File

@@ -1,46 +0,0 @@
<?php
namespace app\api\controller;
use app\api\controller\Base;
use think\Db;
use think\Queue;
use think\Env;
use think\Validate;
class EmailService extends Base
{
public function __construct(\think\Request $request = null)
{
parent::__construct($request);
}
public function refusePassword()
{
$data = $this->request->post();
$rule = new Validate([
"password" => "require"
]);
if (!$rule->check($data)) {
return jsonError($rule->getError());
}
$password = $data['password'];
if (function_exists('openssl_random_pseudo_bytes')) {
$salt = substr(str_replace('+', '.', base64_encode(openssl_random_pseudo_bytes(6))), 0, 8);
} else {
// 使用 mt_rand 作为后备方法
$salt = '';
for ($i = 0; $i < 8; $i++) {
$salt .= chr(mt_rand(33, 126)); // 生成随机字符
}
}
$hashed_password = crypt($password, '$1$' . $salt . '$');
return jsonSuccess(["result"=>$hashed_password]);
// return $hashed_password;
}
}

View File

@@ -355,9 +355,6 @@ class Super extends Controller {
$journal_info = $this->journal_obj->where('journal_id',$journalId)->find();
$zc_num = $this->article_obj->where('accept_sn','like',$journal_info['abbr'].'%')->where('journal_id','<>',$journalId)->where('ctime','>',$start_time)->where('ctime','<',$end_time)->count();
// echo $this->article_obj->getLastSql();die;
$zr_num = $this->article_obj->where('accept_sn','not like',$journal_info['abbr'].'%')->where('journal_id',$journalId)->where('ctime','>',$start_time)->where('ctime','<',$end_time)->count();
//获取全部总数
$mq_num = $this->article_obj
@@ -365,7 +362,6 @@ class Super extends Controller {
->where('ctime','>',$start_time)
->where('ctime','<',$end_time)
->count();
echo $this->article_obj->getLastSql();die;
$res['mq'] = $mq_num;//文章总数
$res['zc'] = $zc_num;//转出文章数
$res['zr'] = $zr_num;//转入文章数

View File

@@ -278,6 +278,52 @@ function search_array_val($arr, $val)
}
}
function sendMyEmail($email,$title,$content){
$mail = new PHPMailer(true);
try {
// 服务器设置
$mail->isSMTP();
$mail->Host = 'smtp.tmrjournals.com.cn'; // SMTP 服务器
$mail->SMTPAuth = true;
$mail->Username = 'wangjinlei@tmrjournals.com.cn'; // SMTP 用户名
$mail->Password = '123456qwe';
// $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; // Enable STARTTLS encryption
// $mail->Port = 587; // TCP port for STARTTLS
// $mail->SMTPDebug = 2; // Enable debugging for detailed output
// $mail->SMTPSecure = ''; // 不使用 SSL 或 TLS
// $mail->Port = 25;
$mail->SMTPSecure = false; // 禁用TLS/SSL加密
$mail->SMTPAutoTLS = false; // 禁用自动TLS加密
$mail->Port = 25; // 非加密的SMTP通常使用端口25
// 收件人设置
$mail->setFrom('wangjinlei@tmrjournals.com.cn', 'tmr');
$mail->addAddress($email, $email); // 添加一个收件人
$mail->addReplyTo('wangjinlei@tmrjournals.com.cn', 'repack');
// 附件(可选)
// $mail->addAttachment('/var/tmp/file.tar.gz');
// $mail->addAttachment('/tmp/image.jpg', 'new.jpg');
// 内容
$mail->isHTML(true); // 设置邮件格式为 HTML
$mail->Subject = $title;
$pre = Env::get('emailtemplete.pre');
$net = Env::get('emailtemplete.net');
$net = str_replace("{{email}}", 'wangjinlei@tmrjournals.com.cn', $net);
$bo = $pre.$content.$net;
$mail->Body = $bo;
$mail->AltBody = $content;
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
}
function GptChar($message,$ckey)
{
$url = 'https://api.openai.com/v1/chat/completions';

View File

@@ -19,7 +19,7 @@
"php": ">=5.4.0",
"topthink/framework": "5.0.*",
"topthink/think-captcha": "1.*",
"phpmailer/phpmailer": "^6.1",
"phpmailer/phpmailer": "^6.9",
"tecnickcom/tcpdf": "^6.3",
"weiwei/api-doc": "^1.6",
"topthink/think-queue": "1.1.4",

View File

@@ -3,7 +3,7 @@
'name' => 'topthink/think',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '881ac3e056b44443399cc70fcd00babeecddaaa0',
'reference' => '1f7220f36e66f33fb9d3867ecb1856a4d2fb0ae5',
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@@ -175,7 +175,7 @@
'topthink/think' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '881ac3e056b44443399cc70fcd00babeecddaaa0',
'reference' => '1f7220f36e66f33fb9d3867ecb1856a4d2fb0ae5',
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),