Server IP : 172.67.158.161 / Your IP : 3.135.189.237 Web Server : LiteSpeed System : Linux business53.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : giankuin ( 1871) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/self/root/proc/thread-self/root/proc/self/root/proc/self/root/home/giankuin/bnnagency.com/wp-content/plugins/web-affiliate/ |
Upload File : |
<?php /* * Plugin Name: Affiliate info use for website template * Description: A WordPress plugin that show info affiliate. * Version: 1.0.4 * Author: BNN * Author URI: https://web.bnn.vn/ * License: GNU General Public License v3 or later * License URI: http://www.gnu.org/licenses/gpl-3.0.html * * Requires at least: 4.0 * Tested up to: 4.7 * Text Domain: web-affiliate * Domain Path: /languages/ * * @package WebAffiliate */ function affiliate_info_menu() { add_menu_page('Affiliate', 'Affiliate Info', 'administrator', __FILE__, 'info_affiliate_settings_page','dashicons-paperclip', 200); add_action( 'admin_init', 'register_info_affiliate_settings' ); } add_action('admin_menu', 'affiliate_info_menu'); function register_info_affiliate_settings() { register_setting( 'affiliate-info-settings-group', 'affiliate_info_option_url' ); } function info_affiliate_settings_page() { ?> <div class="wrap"> <h2>Link get affiliate info</h2> <?php if( isset($_GET['settings-updated']) ) { ?> <div id="message" class="updated"> <p><strong><?php _e('Save Changed') ?></strong></p> </div> <?php } ?> <form method="post" action="options.php"> <?php settings_fields( 'affiliate-info-settings-group' ); ?> <table class="form-table"> <tr valign="top"> <th scope="row">Link Target</th> <td><input size="40" type="text" name="affiliate_info_option_url" placeholder="" value="<?php echo get_option('affiliate_info_option_url'); ?>"/> </td> </tr> </table> <?php submit_button(); ?> </form> </div> <?php } class WebAffiliate { private $title; public $content; public function __construct() { // $this->addMenu(); $this->hook(); } public function hook() { if (!is_admin()) { $link = get_option('affiliate_info_option_url'); $parts = parse_url($_SERVER['REQUEST_URI']); parse_str($parts['query'], $query); $affInfo = [ 'hotline' => '', 'linkweb' => '', 'khau_hieu' => '', 'mau_sac' => '#000', 'ho_ten' => '', ]; if (!isset($_COOKIE['hotline'])) { $data = []; if (isset($query['id'])) { $data['id'] = $query['id']; } $result = $this->CallAPI('GET', $link, $data); if ($result) { $info = json_decode($result, true); foreach ($info as $key => $val) { setcookie($key, $val, time() + (86400 * 15), "/"); $affInfo[$key] = $val; } } } else { $affInfo['hotline'] = $_COOKIE['hotline']; $affInfo['linkweb'] = $_COOKIE['linkweb']; $affInfo['khau_hieu'] = $_COOKIE['khau_hieu']; $affInfo['mau_sac'] = $_COOKIE['mau_sac']; $affInfo['ho_ten'] = $_COOKIE['ho_ten']; } ob_start(); $this->content = '<div class="hien-thi-thong-tin" style="position: fixed; bottom: 0; width: 100%; z-index: 9999999999; background: '.$affInfo['mau_sac'].';text-align: center;"> <div class="row"> <div class="large-4 hide-for-small" style="padding:7px"> <p style="color:white;margin-bottom: 0px;font-weight: normal;"><i class="fa fa-home" aria-hidden="true"></i><a style="color:white" href="'.$affInfo['linkweb'].'" target="_blank"> '.$affInfo['ho_ten'].'</a></p> </div> <div class="large-4 small-12" style="padding:7px;border-left: 1px solid white;border-right: 1px solid white"> <a href="tel:'.$affInfo['hotline'].'"> <p style="color:white;margin-bottom: 0px;font-weight: normal;"><i class="fa fa-phone" aria-hidden="true"></i> Hotline: '.$affInfo['hotline'].'</p></a> </div> <div class="large-4 hide-for-small" style="padding:7px"> <p style="color:white;margin-bottom: 0px;font-weight: normal"><i class="fa fa-sun-o" aria-hidden="true"></i> '.$affInfo['khau_hieu'].'</p> </div> </div> </div>'; add_action('wp_footer', [ $this, 'render_info_aff' ]); return ob_get_clean(); } } function render_info_aff() { ob_start(); echo $this->content; // return ob_get_clean(); } function CallAPI($method, $url, $data = false) { $curl = curl_init(); switch ($method) { case "POST": curl_setopt($curl, CURLOPT_POST, 1); if ($data) curl_setopt($curl, CURLOPT_POSTFIELDS, $data); break; case "PUT": curl_setopt($curl, CURLOPT_PUT, 1); break; default: if ($data) $url = sprintf("%s?%s", $url, http_build_query($data)); } // Optional Authentication: curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($curl, CURLOPT_USERPWD, "username:password"); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($curl); curl_close($curl); return $result; } } new WebAffiliate();