Skip to main content

Posts

Get Remote IP Address in PHP

How to Get Remote IP Address using Core PHP You can use following function to Get Remote IP Address function getRemoteIPAddress() { $ip = $_SERVER['REMOTE_ADDR']; return $ip; } The above code will not work in case your client is behind proxy server. In that case use below function to get real IP address of client. function getRealIPAddr() { if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet { $ip=$_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy { $ip=$_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip=$_SERVER['REMOTE_ADDR']; } return $ip; }

How To Add Syntax Highlighter For Blogger

Adding syntax highlighter to your Blogger will make more beautiful and specific code with formatting to look at. You can use this method to highlight for HTML, CSS, JavaScript, PHP, Python, C, C++, JAVA, PERL, XML, XHTML and much other typical codes by using  code-prettify . Why you will choose code-prettify: 1. code-prettify is built by  Google . 2. It is fully responsive. 3. Easy to use. 4. Faster loading than other syntax highlighters. 5. Access several themes. Click here to view more....

Base64 Encode and Decode String in PHP

How to Encode and Decode String in PHP using Base64 Algorithm You can use following function to Encode and Decode String in PHP function base64url_encode($plainText) { $base64 = base64_encode($plainText); $base64url = strtr($base64, '+/=', '-_,'); return $base64url; } function base64url_decode($plainText) { $base64url = strtr($plainText, '-_,', '+/='); $base64 = base64_decode($base64url); return $base64; }

Send Mail using mail function in PHP

How to Send Mail using mail function in PHP $to = "reciever@gmail.com"; $subject = "Test Message"; $body = "Body of your message here you can use HTML too"; $headers = "From: Your Name\r\n"; $headers .= "Reply-To: info@yoursite.com\r\n"; $headers .= "Return-Path: info@yoursite.com\r\n"; $headers .= "X-Mailer: PHP5\n"; $headers .= 'MIME-Version: 1.0' . "\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; mail($to,$subject,$body,$headers); ?

How to Hide File using VB.Net

Private Sub HideFile(ByVal strFilePath As String) Try Dim strFInfo As New FileInfo(strFilePath) strFInfo.Attributes = FileAttributes.Hidden MessageBox.Show("Successfully Applied.") Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub

Create Service on Remote Machine

Private Sub CrateService(ByVal strComputer As String) Dim objWMIService, colServiceList, objService, errReturn, objSWbemLocator Const OWN_PROCESS = 16 Const NOT_INTERACTIVE = False Const NORMAL_ERROR_CONTROL = 2 Dim strName, strDisplay, strPath As String strName = txtName.Text strDisplay = txtDisplay.Text strPath = txtPath.Text Try objSWbemLocator = CreateObject("WbemScripting.SWbemLocator") If (strComputer = Environment.MachineName.ToString) Then objWMIService = objSWbemLocator.ConnectServer(strComputer, "root\cimv2") Else objWMIService = objSWbemLocator.ConnectServer(strComputer, "root\cimv2", strTargetUser, strTargetPwd) End If objWMIService.Security_.ImpersonationLevel = 3 objService = objWMIService.Get("Win32_BaseService") errReturn = objService.Cr...

Change IE Proxy on Remote Machine

Private Sub ChangeProxy(ByVal IP As String, ByVal Proxy As Boolean, ByVal strAddress As String, ByVal ByPass As Boolean) Dim strComputer Dim strUserName Dim strPassword Dim objLocator Dim objService Dim objRegistry Dim strKeyPath, strValueName, strValue As String Dim dwValue As Integer Const HKEY_CURRENT_USER = &H80000001 strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings" strComputer = IP strUserName = UserName strPassword = Password Try objLocator = CreateObject("WbemScripting.SWbemLocator") If (IP = System.Environment.MachineName) Then objService = objLocator.ConnectServer(strComputer, "Root\Default") Else objService = objLocator.ConnectServer(strComputer, "Root\Default", strUserName, strPassword) End If ob...

Kill Process on Remote Machine

Private Sub ProcessKill(ByVal strIP As String, ByVal PID As Integer) Dim query As Management.ManagementObjectSearcher Dim queryCollection As Management.ManagementObjectCollection Dim management_object1 As Management.ManagementObject Dim msc As Management.ManagementScope Dim co As New Management.ConnectionOptions co.Username = UserName co.Password = Password If (strIP = Environment.MachineName.ToString) Then msc = New Management.ManagementScope("\\" & strIP & "\root\cimv2") Else msc = New Management.ManagementScope("\\" & strIP & "\root\cimv2", co) End If Dim id As String = PID Dim query_command As String = "SELECT * FROM Win32_Process where ProcessId=" & id Dim select_query As Management.SelectQuery = New Management.SelectQuery(query_command) Try query = New Manage...

Ping Network Computer in VB.Net

"Ping" is very basic utility for every network programmer. Here we will discuss ping a computer in Network using VB.Net. We have two methods for pinging a computer. Method 1: Here we will use VB.Net NetworkInformation NameSpace. Public Sub PingStatus(ByVal strComputer As String) Dim pingSender As Ping = New Ping() Dim options As PingOptions = New PingOptions() options.DontFragment = True 'Create a buffer of 32 bytes of data to be transmitted Dim data As String = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" Dim buffer As Byte() = Encoding.ASCII.GetBytes(data) Dim timeout As Integer = 120 Dim reply As PingReply = pingSender.Send(strComputer, timeout, buffer, options) If (reply.Status = IPStatus.Success) Then MessageBox.Show("Ping Successed.") Else MessageBox.Show("Ping Faild.") End If End Sub Method 2: Here we are using .Net inbuil...

Free Disk Space on Remote Computer

Public Sub GetFreeDiskSpace(ByVal strComputer As String, ByVal strUserName As String, ByVal strPwd As String) Dim query As Management.ManagementObjectSearcher Dim queryCollection As Management.ManagementObjectCollection Dim management_object1 As Management.ManagementObject Dim msc As Management.ManagementScope If (strComputer = System.Environment.MachineName) Then msc = New Management.ManagementScope("\\" & strComputer & "\root\cimv2") Else Dim co As New Management.ConnectionOptions co.Username = strUserName co.Password = strPwd msc = New Management.ManagementScope("\\" & strComputer & "\root\cimv2", co) End If Dim query_command As String = "SELECT * FROM Win32_LogicalDisk" Dim select_query As Management.SelectQuery = New Management.SelectQuery(query_command) Try quer...

Get Installed Printer on Netwrok

Public Sub NetworkInstalledPrinter(ByVal strComputer As String, ByVal strUserName As String, ByVal strPwd As String) Try Dim Query As Management.ObjectQuery = New System.Management.ObjectQuery("SELECT * FROM Win32_Printer") Dim moSearcher As Management.ManagementObjectSearcher = New System.Management.ManagementObjectSearcher(Query) Dim moc As Management.ManagementObjectCollection = moSearcher.Get() For Each mo As Management.ManagementObject In moc Dim Pdc As Management.PropertyDataCollection = mo.Properties For Each pd As Management.PropertyData In Pdc Try If (CType(mo("Network"), Boolean)) Then Dim strName As String strName = CType(mo(pd.Name), String) If (strName.StartsWith("\\")) Then MessageBox.Show(str...