S
H
A
R
E

Thursday, May 05, 2011

PHP, Reserved Variables Server

Use Like This $_SERVER[var_name], this list of var_name and the call back result:


'PHP_SELF'
The filename of the currently executing script, relative to the document root. For instance, $_SERVER['PHP_SELF'] in a script at the address http://example.com/test.php/foo.bar would be /test.php/foo.bar. The file constant contains the full path and filename of the current (i.e. included) file. If PHP is running as a command-line processor this variable contains the script name since PHP 4.3.0. Previously it was not available.
'argv'
Array of arguments passed to the script. When the script is run on the command line, this gives C-style access to the command line parameters. When called via the GET method, this will contain the query string.
'argc'
Contains the number of command line parameters passed to the script (if run on the command line).
'GATEWAY_INTERFACE'
What revision of the CGI specification the server is using; i.e. 'CGI/1.1'.



'SERVER_ADDR'
The IP address of the server under which the current script is executing.
'SERVER_NAME'
The name of the server host under which the current script is executing. If the script is running on a virtual host, this will be the value defined for that virtual host.
'SERVER_SOFTWARE'
Server identification string, given in the headers when responding to requests.
'SERVER_PROTOCOL'
Name and revision of the information protocol via which the page was requested; i.e. 'HTTP/1.0';
'REQUEST_METHOD'
Which request method was used to access the page; i.e. 'GET', 'HEAD', 'POST', 'PUT'.
Note:
PHP script is terminated after sending headers (it means after producing any output without output buffering) if the request method was HEAD.
'REQUEST_TIME'
The timestamp of the start of the request. Available since PHP 5.1.0.
'QUERY_STRING'
The query string, if any, via which the page was accessed.
'DOCUMENT_ROOT'
The document root directory under which the current script is executing, as defined in the server's configuration file.
'HTTP_ACCEPT'
Contents of the Accept: header from the current request, if there is one.
'HTTP_ACCEPT_CHARSET'
Contents of the Accept-Charset: header from the current request, if there is one. Example: 'iso-8859-1,*,utf-8'.
'HTTP_ACCEPT_ENCODING'
Contents of the Accept-Encoding: header from the current request, if there is one. Example: 'gzip'.
'HTTP_ACCEPT_LANGUAGE'
Contents of the Accept-Language: header from the current request, if there is one. Example: 'en'.
'HTTP_CONNECTION'
Contents of the Connection: header from the current request, if there is one. Example: 'Keep-Alive'.
'HTTP_HOST'
Contents of the Host: header from the current request, if there is one.
'HTTP_REFERER'
The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.
'HTTP_USER_AGENT'
Contents of the User-Agent: header from the current request, if there is one. This is a string denoting the user agent being which is accessing the page. A typical example is: Mozilla/4.5 [en] (X11; U; Linux 2.2.9 i586). Among other things, you can use this value with get_browser() to tailor your page's output to the capabilities of the user agent.
'HTTPS'
Set to a non-empty value if the script was queried through the HTTPS protocol.
Note: Note that when using ISAPI with IIS, the value will be off if the request was not made through the HTTPS protocol.
'REMOTE_ADDR'
The IP address from which the user is viewing the current page.
'REMOTE_HOST'
The Host name from which the user is viewing the current page. The reverse dns lookup is based off the REMOTE_ADDR of the user.
Note: Your web server must be configured to create this variable. For example in Apache you'll need HostnameLookups On inside httpd.conf for it to exist. See also gethostbyaddr().
'REMOTE_PORT'
The port being used on the user's machine to communicate with the web server.
'SCRIPT_FILENAME'
The absolute pathname of the currently executing script.
Note:
If a script is executed with the CLI, as a relative path, such as file.php or ../file.php, $_SERVER['SCRIPT_FILENAME'] will contain the relative path specified by the user.
'SERVER_ADMIN'
The value given to the SERVER_ADMIN (for Apache) directive in the web server configuration file. If the script is running on a virtual host, this will be the value defined for that virtual host.
'SERVER_PORT'
The port on the server machine being used by the web server for communication. For default setups, this will be '80'; using SSL, for instance, will change this to whatever your defined secure HTTP port is.
'SERVER_SIGNATURE'
String containing the server version and virtual host name which are added to server-generated pages, if enabled.
'PATH_TRANSLATED'
Filesystem- (not document root-) based path to the current script, after the server has done any virtual-to-real mapping.
Note: As of PHP 4.3.2, PATH_TRANSLATED is no longer set implicitly under the Apache 2 SAPI in contrast to the situation in Apache 1, where it's set to the same value as the SCRIPT_FILENAME server variable when it's not populated by Apache. This change was made to comply with the CGI specification that PATH_TRANSLATED should only exist if PATH_INFO is defined. Apache 2 users may use AcceptPathInfo = On inside httpd.conf to define PATH_INFO.
'SCRIPT_NAME'
Contains the current script's path. This is useful for pages which need to point to themselves. The __FILE__ constant contains the full path and filename of the current (i.e. included) file.
'REQUEST_URI'
The URI which was given in order to access this page; for instance, '/index.html'.
'PHP_AUTH_DIGEST'
When running under Apache as module doing Digest HTTP authentication this variable is set to the 'Authorization' header sent by the client (which you should then use to make the appropriate validation).
'PHP_AUTH_USER'
When running under Apache or IIS (ISAPI on PHP 5) as module doing HTTP authentication this variable is set to the username provided by the user.
'PHP_AUTH_PW'
When running under Apache or IIS (ISAPI on PHP 5) as module doing HTTP authentication this variable is set to the password provided by the user.
'AUTH_TYPE'
When running under Apache as module doing HTTP authenticated this variable is set to the authentication type.
'PATH_INFO'
Contains any client-provided pathname information trailing the actual script filename but preceding the query string, if available. For instance, if the current script was accessed via the URL http://www.example.com/php/path_info.php/some/stuff?foo=bar, then $_SERVER['PATH_INFO'] would contain /some/stuff.
'ORIG_PATH_INFO'
Original version of 'PATH_INFO' before processed by PHP. 
For More: visit php.net


Read More!

Monday, May 02, 2011

VB.net Console with Form and Muti-threading


I using VS 2010, lets try it, Make your project with VB language, choose Console Application.
In Console Apllication, you can’t import the windows class (Imports System.Windows.Forms). Because, the references it not included automatically in Console Apllication project, but, it can be set, use this way:

·         On Solution Explorer, klik ‘My Project’ (Project properties and configurations):



·         Choose ‘Refferences’:

·         Click Add:

·         Select “System.Windows.Forms”:

“Click OK”, now you can create form in your console application :-), now you can use this import: Imports System.Windows.Forms.

NEXT: THE CODING

Import System.Windows.Forms in your project, and declaring this

    Dim T1 As New Threading.Thread(AddressOf Thread_one)
    Dim i As Integer = 0

Var I is use for counter, T1 is the thread class object, and Thread_One is the sub program that will run as thread T1.

Create the Main Sub:

    Sub Main()
        Console.WriteLine("Press enter and then the second thread will be run..")
        Console.ReadKey()
        T1.Start()
        Console.Write("Input User: ")
        Console.ReadLine()
        T1.Abort()
    End Sub

And this is the handler of Second Thread:

    Private Sub Thread_one()
        Dim Thread_one_form As New Form
        Dim Thread_one_label As New Label
        Dim i As Integer = 0
        Thread_one_form.Show()
        Thread_one_form.Top = 0
        Thread_one_form.Width = 200
        Thread_one_form.Height = 100
        Thread_one_label.Parent = Thread_one_form
        Thread_one_label.Dock = DockStyle.Top
        Thread_one_form.Text = "Waiting User Input"
        While True
            Thread_one_label.Text = i & " seconds."
            i += 1
            Threading.Thread.Sleep(1000)
            Thread_one_form.Left = (i + 1) * 10
            Thread_one_form.Update()
        End While
    End Sub

This subwill showing the form and wating for user input. U can edit this code for make your application run more better and escape from Not responding form process.

Download Tutorial (docx) and Project (VB2010)

Read More!

Thursday, April 28, 2011

CSharp Rounded Blinking Box in Console


Using VS2008 and written with CSharp Language, The rounded box will be blinking, use a simple timer handler you can try It, and this is the code:
using System;
using System.Threading;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Kotak_Dekorasi k = new Kotak_Dekorasi();
            k.New(1, 1, 78, 5, 200);
           
        re:
           // j.Jalan();
            k.Jalan();
            Console.ReadKey();
            k.Berhenti();
            //j.Berhenti();
            Console.ReadKey();
            goto re;
        }
    }
    class Kotak_Dekorasi
    {
        TimerCallback TmH;
        public Timer tm;
        static char c1 = '*', c2 = ' ';
        static int x1, y1, x2, y2, d;
          public void New(int xx1, int yy1, int xx2, int yy2, int delay)
        {
            x1 = xx1; x2 = xx2; y1 = yy1; y2 = yy2; d = delay;
        }
          public void Jalan()
          {
              TmH = new TimerCallback(kedip);
              tm = new Timer(TmH, 0, 0, 300);

          }
          public void Berhenti()
          {
              tm.Dispose();
          }
        static void kedip(object kondisi) //TImer Handler bro..,
        {
            int i,j;
             Console.ForegroundColor = ConsoleColor.Green;
            //Atas-Bawah
           for (i = x1; i <= x2; i++)
            {
                Console.SetCursorPosition(i, y1);
                lip(i);
                Console.SetCursorPosition(i, y2);
                lip(i + (y2 - y1));
            }
            //Kanan-Kiri
            for (j = y1; j <= y2; j++)
            {
                Console.SetCursorPosition(x2, j) ;
                lip((x2-x1) + j);
                Console.SetCursorPosition(x1, j);
                lip(j);
            }

            char x =c1;c1 = c2; c2 = x;
        }

        static  void lip(int i)
        {
            if (i % 2 == 0)
                Console.Write(c1);
            else Console.Write(c2);
        }

    }
}

Read More!

VB.net Create Simple Text Effect Following Mouse

This Program will displaying text on screen and following mouse with simple effect. Just a simple, have some conntrol mouse manipulation, and timer for animation.


This project using NetFramework 3.5, I write it with Visual studio 2008, Would you like to try??
Ok, lets make a new VB project in Visual studio. and then... copy the code bellow:



Public Class Form
    Dim str As String = ""
    Dim StrLen As Integer = 0
    Dim pos As Integer = 0
    Const TxWidth As Integer = 17
    Dim Lb(30) As Label
    Dim WithEvents tm As New Timer()
    Dim WithEvents TmIkuti As New Timer()


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        str = "This A Simple Mouse Effect"
        Me.ShowInTaskbar = False
        Me.TopMost = True
        StrLen = str.Length
        Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
        Me.BackColor = Color.White
        Me.TransparencyKey = Color.White
        TataHuruf()
    End Sub

    Private Sub TataHuruf()
        For i = 0 To StrLen - 1
            Lb(i) = New Label
            Lb(i).Text = str(i)
            Lb(i).Width = TxWidth
            Lb(i).Font = New Font("Calibri", 12, FontStyle.Bold)
            Lb(i).Left = TxWidth * i
            Lb(i).Top = 5
            Lb(i).Parent = Me
            Lb(i).Show()
        Next
        Me.Height = Lb(0).Height + 5
        Me.Width = TxWidth * StrLen
        tm.Interval = 80
        tm.Start()
        TmIkuti.Interval = 10
        TmIkuti.Start()
    End Sub

    Private Sub Animasi() Handles tm.Tick
        Lb(pos).Top = 0
        Lb(pos).ForeColor = Color.Red
        Dim pr As Integer = PosMovPrev(pos)
        Lb(pr).Top = 5
        Lb(pr).ForeColor = Color.Black
        PosMoveNext()
    End Sub

    Private Sub IkutiMouse_x() Handles TmIkuti.Tick
        Try
            Me.Left = Control.MousePosition.X - (Me.Width \ 2)
            Me.Top = Control.MousePosition.Y
        Catch ex As Exception

        End Try
    End Sub

    Private Sub PosMoveNext()
        If pos >= (StrLen - 1) Then
            pos = 0
        Else
            pos += 1
        End If
        If Trim(Lb(pos).Text) = "" Then PosMoveNext()
    End Sub
    Private Function PosMovPrev(ByVal n As Integer) As Integer
        If n <= 0 Then
            n = StrLen - 1
        Else
            n -= 1
        End If
        If Trim(Lb(n).Text) = "" Then
            Return PosMovPrev(n)
        Else
            Return n
        End If
    End Function
End Class

Read More!

Sunday, April 17, 2011

VB.net DataGridView, Move Row Item By Draging






Download Source (VB.net 2010)


This a sample code how to moving DataGridView rows item with drag and droping, you can move item to every line, check it!

I using this code for get the index of rows where user droping a data:

Private Sub DataGridView1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles DataGridView1.DragDrop

        Dim CP As Point = DataGridView1.PointToClient(New Point(e.X, e.Y))

        Dim RowDestination As Integer = DataGridView1.HitTest(CP.X, CP.Y).RowIndex

        Dim RowSource As Integer = e.Data.GetData("System.String")

        If RowDestination >= 0 Then

            Dim tmp(0 To DataGridView1.Rows(0).Cells.Count - 1)

            'saving Cells

            For i = 0 To tmp.Count - 1

                tmp(i) = DataGridView1.Rows.Item(RowSource).Cells(i).Value

            Next



            DataGridView1.Rows.RemoveAt(RowSource)

            DataGridView1.Rows.Insert(RowDestination, 1)

            'Aplly Saved Cells

            For i = 0 To tmp.Count - 1

                DataGridView1.Rows(RowDestination).Cells(i).Value = tmp(i)

            Next i

            DataGridView1.Rows(RowDestination).Selected = True

        End If

    End Sub
Read More!

Friday, April 08, 2011

C++ Delay Procedure

#include

void delay(unsigned int tick)
{ //klampok_child@yahoo.co.id
 int tmp = (clock()+tick);
 while (clock() <= tmp){};
};

Read More!

Java. Compile & Run Using Command Prompt

This a sample code, save as "app1.java":

public class app1 {
public static void main(String arg[]){
    System.out.println("Haiii haha.. \nThis Ur Java Code");
}
}


This Compiler created from cmd, save as "java_Compile&Run.cmd":

set c=C:\Program Files\Java\jdk1.6.0_23\jre\lib\rt.jar
echo off & cls
javac -Xbootclasspath:"%c%" -classpath . app1.java
java -Xbootclasspath:"%c%" -classpath . app1
pause
rem klampok_child@yahoo.co.id

Place app1.java & java_Compile&Run.cmd in one folder, and double click the cmd file (execute) and see it.
javac is the main java compiler, java is interprenter to running java program (byte-code).
Have problem, please read it:
>  Make sure you have jdk1.6.0_23 installed on your windows
>  Make sure you was write java code correctly (its case-sensitive)

Try it :-)
Read More!

Thursday, March 31, 2011

VB .net Save Program Setting in Registry

Set or Add value to registry:
        Application.UserAppDataRegistry.SetValue("key", "value")


Get or Load value from registry:
        Application.UserAppDataRegistry.GetValue("key")

value will saved into registry, and the location is "HKEY_CURRENT_USER\Software\" and path is "Developer\application name\version".
 This a sample:

HKEY_CURRENT_USER\Software\MyCompany\My VB.net program\1.0.0.0
Read More!

Wednesday, January 26, 2011

C++, Get all parameter there was sent by (DOS/CMD Mode)

#include
#define uli unsigned long int
/*
 Get all parameter there was sent by (DOS/CMD Mode)
  ex :
          jal.exe -this is
  Then the parameter is:
-this is
*/
void main(int arc, char *ar[])
{
// arc:count of parameter(split with space)
// ar: 2D array include string parameter
int n=0,i;
char cmd[255]; //maksimal argument
char *cek = ar[1];
for (int j=1;j
   i=0;
    do{
        cmd[n] = ar[j][i];
       i++; n++;
   }while(ar[j][i]!=0);
cmd[n]=' ';
n++;
};
cmd[n]='\0'; //null terminated string
//Show All Parameter command
cout << "----------------------\nparameter: "<< cmd << '\n';
}
// by: Klampok_Child@yahoo.co.id


Read More!

TPW StrToInt IntToStr

function StrToInt(s:char):integer ;
begin
StrToInt := ord(s)-48;
end;

function IntToStr(ii : longint): string;
var s : string[30];
begin
    str(ii, s);
    IntToStr := s;
end;
Read More!