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 :
IppanelProvider.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 IppanelProvider implements ProviderInterface { private $api_key; private $originator; public function __construct($settings) { $this->api_key = $settings['api_key'] ?? ''; $this->originator = $settings['originator'] ?? '+98100011'; // Default originator } public function send_pattern($to, $pattern_id, $params) { $url = "https://ippanel.com/services/rest/v1.0/sms/send/pattern"; $body = [ 'pattern_code' => $pattern_id, 'originator' => $this->originator, 'recipient' => $this->sanitize_phone($to), 'values' => $this->reformat_params($params) ]; $headers = [ 'Authorization' => 'AccessKey ' . $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://ippanel.com/services/rest/v1.0/sms/send/simple"; $body = [ 'originator' => $this->originator, 'recipient' => $this->sanitize_phone($to), 'message' => $message ]; $headers = [ 'Authorization' => 'AccessKey ' . $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://ippanel.com/services/rest/v1.0/credit"; $headers = [ 'Authorization' => 'AccessKey ' . $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['code']) && $data['code'] === 0; } private function process_balance_response($body) { if (empty($body)) { \WooCommersa\Core\Logger::log('خطای IPPanel: پاسخ سرور خالی است.', 'error', 'درگاه IPPanel'); return false; } $data = json_decode($body, true); if (!$data) { \WooCommersa\Core\Logger::log('خطای IPPanel: فرمت پاسخ JSON معتبر نیست. پاسخ دریافت شده: ' . substr($body, 0, 500), 'error', 'درگاه IPPanel'); return false; } if (isset($data['data']['credit'])) { return (float)$data['data']['credit']; } \WooCommersa\Core\Logger::log('خطای IPPanel: ساختار پاسخ نامعتبر است یا اعتبار یافت نشد. پاسخ: ' . $body, 'error', 'درگاه IPPanel'); return false; } private function sanitize_phone($phone) { $phone = preg_replace('/[^0-9]/', '', $phone); if (substr($phone, 0, 2) === '98') return '+' . $phone; if (substr($phone, 0, 1) === '0') return '+98' . substr($phone, 1); return '+98' . $phone; } private function reformat_params($params) { // IPPanel expects simple key-value pairs in 'values' array $formatted = []; foreach ($params as $key => $val) { $formatted[$key] = (string)$val; } return $formatted; } }