first commit

This commit is contained in:
LAPTOP-V9RRD1TL\Michelle's Computer
2025-07-21 21:38:17 +08:00
commit f8f8fcaf96
2529 changed files with 227800 additions and 0 deletions
+96
View File
@@ -0,0 +1,96 @@
<?php
require( __DIR__.'/../plugins/PHPMailer/src/Exception.php' ) ;
require( __DIR__.'/../plugins/PHPMailer/src/PHPMailer.php' ) ;
require( __DIR__.'/../plugins/PHPMailer/src/SMTP.php' ) ;
use PHPMailer\PHPMailer\PHPMailer ;
use PHPMailer\PHPMailer\Exception ;
class Mailer {
private $smtp = MAILSMTP ;
private $host = MAILHOST ;
private $username = MAILUSERNAME ;
private $password = MAILPASSWORD ;
private $port = MAILPORT ;
public $from = '' ;
public $fromname = '' ;
public $to = [] ;
public $cc = [] ;
public $bcc = [] ;
public $subject = '' ;
public $body = '' ;
public function sendAttachment($path, $filename){
$this->attachment[0] = $path;
$this->attachment[1] = $filename;
}
public function from( $from ){
$this->from = $from ;
}
public function to( $to ){
$this->to = $to ;
}
public function cc( $cc ){
$this->cc = $cc ;
}
public function bcc( $bcc ){
$this->bcc = $bcc ;
}
public function subject( $subject ){
$this->subject = $subject ;
}
public function body( $body ){
$this->body = $body ;
}
public function send(){
$mail = new PHPMailer ;
// Server settings
if ( $this->smtp == 'yes' ){
// $mail->isSMTP() ;
// $mail->SMTPDebug = 1 ;
$mail->Host = $this->host ;
$mail->SMTPAuth = true ;
$mail->Username = $this->username ;
$mail->Password = $this->password ;
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS ;
$mail->SMTPAuth = true ;
$mail->Port = $this->port ;
}
// from
$mail->setFrom( $this->from, $this->fromname ) ;
// send to / cc / bcc
foreach ( $this->to as $k => $v ){ $mail->addAddress( $v ) ; }
foreach ( $this->cc as $k => $v ){ $mail->addCC( $v ) ; }
foreach ( $this->bcc as $k => $v ){ $mail->addBCC( $v ) ; }
$mail->Subject = $this->subject ;
if(count($this->attachment) > 0){
$mail->AddAttachment($this->attachment[0], $this->attachment[1]);
}
$mail->isHTML(true) ;
$mail->msgHTML( $this->body ) ;
if ( !$mail->send() ) {
return false ;
}else {
return true ;
}
}
}
?>
+77
View File
@@ -0,0 +1,77 @@
<?php
class Otp {
private $table = 'otps' ;
public $otpid = '' ;
public $where = '' ;
// for insert or update
public $type = '' ;
public $field = [] ;
public function __construct( $otpid = '' ){
$this->otpid = $otpid ;
}
public function allowOtp( $mobile ){
$query = new Database( $this->table ) ;
$query->filter = 'otpid' ;
$query->where = "ip_address = '".$_SERVER["REMOTE_ADDR"]."' AND created_at > '".date('Y-m-d H:i:s', strtotime('-1 minute'))."' AND send_to = '".$mobile."'" ;
$query->limit = '1' ;
$select = $query->select() ;
if ( $select['status'] == '200' ){
return json_return( '301' ) ;
}else{
return json_return( '200' ) ;
}
}
public function check( $otpid, $refertype, $referid, $otp ){
if ( $otp == '' ) return json_return( '300' ) ;
$query = new Database( $this->table ) ;
$query->filter = 'count, code, created_at' ;
$query->where = "otpid = '".$otpid."' AND refertype = '".$refertype."' AND referid = '".$referid."'" ;
$query->limit = '1' ;
$select = $query->select() ;
if ( $select['status'] == '200' ){
$data = $select['data']['0'] ;
// update count
$count = ( $data['count'] + 1 ) ;
$query->field = [ 'count' => $count ] ;
$query->save() ;
if ( $count > 3 ) return json_return( '302' ) ;
if ( $data['created_at'] < date('Y-m-d H:i:s', strtotime('-1 minute')) ) return json_return( '292' ) ;
if ( $data['code'] != $otp ) {
$count++ ;
if ( $count > 3 ) return json_return( '302' ) ;
return json_return( '283' ) ;
}
return json_return( '200' ) ;
}
return json_return( '291' ) ;
}
public function save(){
$save = new Database( $this->table ) ;
$save->type = 'insert' ;
$save->field = $this->field ;
if ( $save->save() ){
return json_return( '200', [ 'id' => $save->id ] ) ;
}
return json_return( '205' ) ;
}
}
?>
+47
View File
@@ -0,0 +1,47 @@
<?php
class Sms {
private $endpoint = SMSENDPOINT ;
private $id = SMSID ;
private $token = SMSTOKEN ;
private $secret = SMSSECRET ;
private $company = SMSCOMPANY ;
public $to = '' ;
public $message = '' ;
public function send() {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $this->endpoint,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => 'user_id='.urlencode( $this->id ).'&token='.urlencode( $this->token ).'&sign='.urlencode( md5( $this->id . $this->token . $this->secret ) ).'&company=' . urlencode( $this->company ) . '&to='.urlencode( '+'.str_replace( [ '-', '+' ], '', $this->to ) ).'&msg='.urlencode( $this->message ),
CURLOPT_HTTPHEADER => array( 'Content-Type: application/x-www-form-urlencoded' ),
));
$response = curl_exec($curl);
curl_close($curl);
$result = json_decode( $response, true ) ;
saveLog( 'sms', 'Sms', 'user_id='.urlencode( $this->id ).'&token='.urlencode( $this->token ).'&sign='.urlencode( md5( $this->id . $this->token . $this->secret ) ).'&company=' . urlencode( $this->company ) . '&to='.urlencode( '+'.str_replace( [ '-', '+' ], '', $this->to ) ).'&msg='.urlencode( $this->message ), $result ) ;
if ( $result['status'] == '200' ) {
return true ;
}
return false ;
}
}
?>
File diff suppressed because it is too large Load Diff