CGI Callback function

Discussion in 'Programming' started by rsolomou, Jul 22, 2007.

  1. #1
    Hello,

    I am soon releasing a new script written in CGI and Perl, and would like some help on adding a callback function.

    I want the script to send an e-mail to my e-mail address whenever a copy of the script has been installed on a server. Therefore, I can handle which copies are pirated and which are not.

    I heard there is a way to input PHP functions inside CGI files. Is this correct? If so could somebody help me convert this PHP code into code that can be put in a CGI file?

    if ("POST" == getenv("REQUEST_METHOD")) {
    	$query_array = explode(";", $query);
    	for ($i = 0; count($query_array) > $i; ++$i) {
    		$db->query($query_array[$i]);
    	}
    	for ($i = 1; 21 > $i; ++$i) {
    		$db->query($q[$i]);
    	}
    	$md5password = md5($_POST["password"]);
    	$host = getenv("HTTP_HOST");
    	
    	$db->query("INSERT INTO `users` (users_id,users_general_id,users_username,users_password,users_email,users_name) VALUES ('1','1','{$_POST["username"]}','$md5password','{$_POST["email"]}','{$_POST["name"]}')");
    	@mail("installations@myscriptinstallations.com","My Script Install Alert","Script installed at $host\r\nBy {$_POST["username"]} {$_POST["email"]}\r\nName of script: My Script Name");
    print <<<OK
    
    Code (markup):
    Otherwise, if this is not correct, can somebody tell me how I can create a CGI Callback function that will work similarly to the PHP function above?

    Thank you for your time.
     
    rsolomou, Jul 22, 2007 IP