Server IP : 108.163.255.210 / Your IP : 3.140.185.250 Web Server : Apache System : Linux blossom.urlnameserver.com 3.10.0-1160.80.1.el7.x86_64 #1 SMP Tue Nov 8 15:48:59 UTC 2022 x86_64 User : ( 1172) PHP Version : 7.2.34 Disable Function : eval,escapeshellarg,proc_close,proc_get_status,proc_nice,proc_open,symlink,system,pcntl_exec,getrusage,chown,chgp,closelog,openlog,syslog,define_syslog_variables,php_ini_loaded_file,getservbyname,getservbyport,posix_getgid,posix_getgrgid,proc_terminate,pfsockopen,apache_child_terminate,posix_mkfifo,posix_setpgid,posix_setuid,hypot,pg_host,pos,posix_access,posix_getcwd,posix_getservbyname,myshellexec,getpid,posix_getsid,posix_isatty,posix_kill,posix_mknod,posix_setgid,posix_setsid,posix_setuid,posix_times,posix_uname,ps_fill,posix_getpwuid,global,ini_restore,zip_open,zip_read,rar_open,bzopen,bzread,bzwrite,apache_get_modules,apache_get_version,phpversionphpinfo,php_ini_scanned_files,get_current_user,disk_total_space,diskfreespace,leak,imap_list,hypo,filedump,safe_mode,getmygid,apache_getenv,apache_setenv,bzread,bzwrite,bzopen,phpini,higlight_file,dos_conv,get_cwd,er_log,cmd,e_name,vdir,get_dir,only_read,ftok,ftpexec,posix_getpwnam,mysql_list_dbs,disk_free_space,session_save_path,confirm_phpdoc_compiled,zip_entry_rea,php_u,psockopen,crack_opendict,crack_getlastmessage,crack_closedict,crack_check,fpassthru,posix_get_last_error,posix_getlogin,posix_getgroups,posix_strerror,posix_getrlimit,posix_getpgrp,posix_getgrnam,pos,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/unilinki/public_html/shop/app/Utility/ |
Upload File : |
<?php namespace App\Utility; class NagadUtility { /** * Generate Random string */ public static function generateRandomString($length = 40) { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $charactersLength = strlen($characters); $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, $charactersLength - 1)]; } return $randomString; } /** * Generate public key */ public static function EncryptDataWithPublicKey($data) { $pgPublicKey = env('NAGAD_PG_PUBLIC_KEY'); $public_key = "-----BEGIN PUBLIC KEY-----\n" . $pgPublicKey . "\n-----END PUBLIC KEY-----"; // echo $public_key; // exit(); $key_resource = openssl_get_publickey($public_key); openssl_public_encrypt($data, $crypttext, $key_resource); return base64_encode($crypttext); } /** * Generate signature */ public static function SignatureGenerate($data) { $merchantPrivateKey = env('NAGAD_MERCHANT_PRIVATE_KEY'); $private_key = "-----BEGIN RSA PRIVATE KEY-----\n" . $merchantPrivateKey . "\n-----END RSA PRIVATE KEY-----"; // echo $private_key; // exit(); openssl_sign($data, $signature, $private_key, OPENSSL_ALGO_SHA256); return base64_encode($signature); } /** * get clinet ip */ public static function get_client_ip() { $ipaddress = ''; if (isset($_SERVER['HTTP_CLIENT_IP'])) $ipaddress = $_SERVER['HTTP_CLIENT_IP']; else if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) $ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR']; else if (isset($_SERVER['HTTP_X_FORWARDED'])) $ipaddress = $_SERVER['HTTP_X_FORWARDED']; else if (isset($_SERVER['HTTP_FORWARDED_FOR'])) $ipaddress = $_SERVER['HTTP_FORWARDED_FOR']; else if (isset($_SERVER['HTTP_FORWARDED'])) $ipaddress = $_SERVER['HTTP_FORWARDED']; else if (isset($_SERVER['REMOTE_ADDR'])) $ipaddress = $_SERVER['REMOTE_ADDR']; else $ipaddress = 'UNKNOWN'; return $ipaddress; } public static function DecryptDataWithPrivateKey($crypttext) { $merchantPrivateKey = env('NAGAD_MERCHANT_PRIVATE_KEY'); $private_key = "-----BEGIN RSA PRIVATE KEY-----\n" . $merchantPrivateKey . "\n-----END RSA PRIVATE KEY-----"; openssl_private_decrypt(base64_decode($crypttext), $plain_text, $private_key); return $plain_text; } public static function HttpPostMethod($PostURL, $PostData) { $url = curl_init($PostURL); $posttoken = json_encode($PostData); $header = array( 'Content-Type:application/json', 'X-KM-Api-Version:v-0.2.0', 'X-KM-IP-V4:' . self::get_client_ip(), 'X-KM-Client-Type:PC_WEB' ); curl_setopt($url, CURLOPT_HTTPHEADER, $header); curl_setopt($url, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($url, CURLOPT_RETURNTRANSFER, true); curl_setopt($url, CURLOPT_POSTFIELDS, $posttoken); curl_setopt($url, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($url, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($url, CURLOPT_SSL_VERIFYPEER, 0); $resultdata = curl_exec($url); $ResultArray = json_decode($resultdata, true); curl_close($url); return $ResultArray; } public static function HttpGet($url) { $ch = curl_init(); $timeout = 10; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/0 (Windows; U; Windows NT 0; zh-CN; rv:3)"); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $file_contents = curl_exec($ch); echo curl_error($ch); curl_close($ch); return $file_contents; } }