Website : phonehp.ir
backdoor
Warning
: Undefined variable $backdoor in
/home/nehpir/public_html/goods.php
on line
326
Home
Console
Warning
: Undefined variable $backdoor in
/home/nehpir/public_html/goods.php
on line
326
Warning
: Undefined variable $backdoor in
/home/nehpir/public_html/goods.php
on line
326
Warning
: Undefined variable $backdoor in
/home/nehpir/public_html/goods.php
on line
326
Warning
: Undefined variable $backdoor in
/home/nehpir/public_html/goods.php
on line
326
Warning
: Undefined variable $backdoor in
/home/nehpir/public_html/goods.php
on line
326
Warning
: Undefined variable $backdoor in
/home/nehpir/public_html/goods.php
on line
326
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
nehpir
/
www
/
wp-content
/
plugins
/
woocommersa
/
includes
/
Services
/
SMS
/
Providers
/
Filename :
SmsirProvider.php
back
Warning
: Undefined variable $file in
/home/nehpir/public_html/goods.php
on line
545
Copy
<?php namespace WooCommersa\Services\SMS\Providers; use WooCommersa\Services\SMS\ProviderInterface; if (!defined('ABSPATH')) exit; class SmsirProvider implements ProviderInterface { private $api_key; private $settings; public function __construct($settings) { $this->api_key = $settings['api_key'] ?? ''; $this->settings = $settings; } public function send_pattern($to, $pattern_id, $params) { $url = "https://api.sms.ir/v1/send/verify"; $parameters = []; foreach ($params as $name => $value) { $parameters[] = [ 'name' => $name, 'value' => (string)$value ]; } $body = [ 'mobile' => $to, 'templateId' => (int)$pattern_id, 'parameters' => $parameters ]; $headers = [ 'X-API-KEY' => $this->api_key, 'Content-Type' => 'application/json' ]; $response = wp_remote_post($url, [ 'timeout' => 15, 'headers' => $headers, 'body' => json_encode($body), 'sslverify' => false ]); if (is_wp_error($response)) { return $this->send_curl($url, 'POST', $headers, $body); } return $this->process_send_response(wp_remote_retrieve_body($response)); } public function send_message($to, $message) { $url = "https://api.sms.ir/v1/send/bulk"; $body = [ 'lineNumber' => (int)($this->settings['originator'] ?? 0), 'messageText' => $message, 'mobiles' => [$to], 'sendDateTime' => null ]; $headers = [ 'X-API-KEY' => $this->api_key, 'Content-Type' => 'application/json' ]; $response = wp_remote_post($url, [ 'timeout' => 15, 'headers' => $headers, 'body' => json_encode($body), 'sslverify' => false ]); if (is_wp_error($response)) { return $this->send_curl($url, 'POST', $headers, $body); } return $this->process_send_response(wp_remote_retrieve_body($response)); } public function get_balance() { $url = "https://api.sms.ir/v1/credit"; $headers = [ 'X-API-KEY' => $this->api_key ]; $response = wp_remote_get($url, [ 'timeout' => 15, 'headers' => $headers, 'sslverify' => false ]); if (is_wp_error($response)) { return $this->get_balance_curl($url, $headers); } return $this->process_balance_response(wp_remote_retrieve_body($response)); } private function send_curl($url, $method, $headers, $body) { if (!function_exists('curl_init')) return false; $curl_headers = []; foreach ($headers as $key => $val) { $curl_headers[] = "$key: $val"; } $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_TIMEOUT, 15); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); curl_setopt($ch, CURLOPT_HTTPHEADER, $curl_headers); $result = curl_exec($ch); curl_close($ch); return $this->process_send_response($result); } private function get_balance_curl($url, $headers) { if (!function_exists('curl_init')) return false; $curl_headers = []; foreach ($headers as $key => $val) { $curl_headers[] = "$key: $val"; } $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_TIMEOUT, 15); curl_setopt($ch, CURLOPT_HTTPHEADER, $curl_headers); $result = curl_exec($ch); curl_close($ch); return $this->process_balance_response($result); } private function process_send_response($body) { if (empty($body)) return false; $data = json_decode($body, true); return isset($data['status']) && $data['status'] === 1; } private function process_balance_response($body) { if (empty($body)) { \WooCommersa\Core\Logger::log('خطای Sms.ir: پاسخ سرور خالی است.', 'error', 'درگاه Sms.ir'); return false; } $data = json_decode($body, true); if (!$data) { \WooCommersa\Core\Logger::log('خطای Sms.ir: فرمت پاسخ JSON معتبر نیست. پاسخ دریافت شده: ' . substr($body, 0, 500), 'error', 'درگاه Sms.ir'); return false; } if (isset($data['status']) && $data['status'] === 1 && isset($data['data'])) { return (float)$data['data']; } \WooCommersa\Core\Logger::log('خطای Sms.ir: ساختار پاسخ نامعتبر است. پاسخ: ' . $body, 'error', 'درگاه Sms.ir'); return false; } }