示例#1
0
function set_active_state($vermutung_id, $new_state)
{
    $connection = get_db_connection();
    $update_query = sprintf("UPDATE vermutung SET active = '%s' WHERE id = '%s'", mysql_real_escape_string($new_state), mysql_real_escape_string($vermutung_id));
    $result = mysql_query($update_query);
    mysql_close($connection);
    return $result;
}
function exec_query($sql)
{
    static $conn = null;
    if ($conn == null) {
        $conn = get_db_connection();
    }
    if (mysql_query($sql, $conn) === FALSE) {
        error_out(500, "MySQL Error: " . mysql_error($conn) . "; running query: {$sql}");
    }
}
示例#3
0
function users_getById($id)
{
    $db = get_db_connection();
    $tmp = $db->query("SELECT * from users WHERE id = {$id}");
    if ($tmp->num_rows != 0) {
        $user = $tmp->fetch_assoc();
    } else {
        $user = false;
    }
    return $user;
}
示例#4
0
function list_all_hackers()
{
    $db = get_db_connection();
    $hackers = $db->select('parameter_tampering', '*');
    $output = "<pre><table>";
    foreach ($hackers as $hacker) {
        $output .= "<tr><td>" . $hacker["id"] . ". " . $hacker["name"] . " booked " . $hacker["number_of_tickets"] . " and paid " . $hacker["amount"] . "\$ . (Email: " . $hacker["email"] . " ) </td></tr>";
    }
    $output .= "</table></pre>";
    return $output;
}
示例#5
0
function photos_getByUser($id)
{
    $db = get_db_connection();
    $tmp = $db->query("SELECT * FROM photo WHERE user_id = {$id}");
    if ($tmp->num_rows != 0) {
        while ($row = $tmp->fetch_assoc()) {
            $photo[] = $row;
        }
    } else {
        $photo = [];
    }
    return $photo;
}
示例#6
0
function albums_getById($id)
{
    $db = get_db_connection();
    if (is_null($id)) {
        return false;
    }
    $tmp = $db->query("SELECT * FROM albums WHERE id = {$id}");
    if ($tmp->num_rows != 0) {
        $a = $tmp->fetch_assoc();
    } else {
        $a = false;
    }
    return $a;
}
示例#7
0
 function getProjectsByTech($techID)
 {
     try {
         $db = get_db_connection();
         $stmt = $db->prepare("SELECT projects.* FROM projects\n                                JOIN site_techs ON projects.project_id = site_techs.project_id\n                                JOIN techniques ON site_techs.tech_id = techniques.tech_id\n                                WHERE techniques.tech_id = ?;");
         $stmt->bindParam(1, $techID, PDO::PARAM_INT);
         $stmt->execute();
         while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
             $this->name[] = $row['name'];
             $this->url[] = $row['url'];
             $this->github[] = $row['github'];
             $this->projectID[] = $row['project_id'];
             $this->imagePath[] = $row['image_url'];
         }
     } catch (Exception $e) {
         echo "Fehler beim Verbinden zur Datenbank";
     }
 }
 /**
  * Will attempt to save the current record
  * An INSERT will be performed if the primary key for $this is not already populated
  * An UPDATE will be performed otherwise
  * Various options will be available within the function --> still under construction(sanitize,quote,includeEmpties,includeNulls)
  * @param string/array $listOfFields --> determines which fields are to be saved (single fieldname string or indexed array of fieldnames)
  * @return bool
  */
 public function save($listOfFields = "*")
 {
     //If user passes *, then we'll attempt to save all columns (except for the primary key) to the database
     if ($listOfFields == '*') {
         $listOfFields = $this->allFieldsWithoutKeys;
     } elseif (!is_array($listOfFields)) {
         $listOfFields = array((string) $listOfFields);
     }
     $db = get_db_connection();
     //Create an assoc array of all the values we're about to save
     $nameValuePairs = $this->GetFieldsAsAssocArray($listOfFields);
     $field_values = array_values($nameValuePairs);
     $field_names = array_keys($nameValuePairs);
     array_unshift($field_values, $this->GetBoundParamTypeString($field_names));
     if (empty($this->test_pk)) {
         //INSERT new record when this class's primary key property is empty
         $sql = 'INSERT INTO `test`' . ' (`' . implode('`, `', $field_names) . '`)' . ' VALUES (' . str_repeat('?,', count($field_names) - 1) . '?) ';
         $rs = $db->query($sql, null, null, $field_values);
         if ($rs) {
             $this->test_pk = $db->insertID();
             return true;
         } else {
             return false;
         }
     } else {
         //UPDATE existing record based on this class's primary key
         $field_values[0] = $field_values[0] . $this->GetBoundParamTypeString(array('test_pk'));
         $sql = 'UPDATE `test` SET ' . '`' . implode('`=?, `', $field_names) . '`=? ' . '   WHERE `test_pk` = ?';
         $field_values[] = $this->test_pk;
         $rs = $db->query($sql, null, null, $field_values);
         if ($rs) {
             $this->test_pk = $db->insertID();
             return true;
         } else {
             return false;
         }
     }
 }
示例#9
0
function &default_context($make_session)
{
    /*
        Argument is a boolean value that tells the function whether to make a
        session or not.
    */
    $db =& get_db_connection();
    /* change character set to utf8 */
    $db->query("SET NAMES utf8mb4");
    //$db->query("SET CHARACTER SET 'utf8'");
    $user = null;
    $type = get_preferred_type($_GET['type'] ? $_GET['type'] : $_SERVER['HTTP_ACCEPT']);
    if ($type == 'text/html' && $make_session) {
        // get the session user if there is one
        session_set_cookie_params(86400 * 31, get_base_dir(), null, false, true);
        session_start();
        $user = cookied_user($db);
    }
    // Smarty is created last because it needs $_SESSION populated
    $sm =& get_smarty_instance($user);
    $ctx = new Context($db, $sm, $user, $type);
    return $ctx;
}
示例#10
0
<?php

require_once '../admin/config.php';
function get_db_connection()
{
    $db = new pdo(DB_DRIVER . ":dbname=" . DB_NAME . ";charset=utf8;host=" . DB_HOST, DB_USER, DB_PASS);
    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    return $db;
}
function __autoload($class)
{
    require '../classes/class.' . $class . '.php';
}
$techID = $_POST['techID'];
try {
    $db = get_db_connection();
    $stmt = $db->prepare("SELECT projects.* FROM projects\n                                JOIN site_techs ON projects.project_id = site_techs.project_id\n                                JOIN techniques ON site_techs.tech_id = techniques.tech_id\n                                WHERE techniques.tech_id = ?;");
    $stmt->bindParam(1, $techID, PDO::PARAM_INT);
    $stmt->execute();
    while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
        $name[] = $row['name'];
        $url[] = $row['url'];
        $github[] = $row['github'];
        $projectID[] = $row['project_id'];
        $imagePath[] = $row['image_url'];
    }
} catch (Exception $e) {
    echo "Fehler beim Verbinden zur Datenbank";
}
$countTechs = count($name);
echo "Anzahl: {$countTechs}<br>";
示例#11
0
文件: default.php 项目: quilime/mus
<?php

ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . '../lib');
require_once 'init.php';
require_once 'data.php';
require_once 'output.php';
list($response_format, $response_mime_type) = parse_format($_GET['format'], 'html');
$dbh =& get_db_connection();
if (get_request_user()) {
    // auth stuff here
}
$dbh = null;
$sm = get_smarty_instance();
if (get_request_user()) {
    // secure template vars here
}
header("Content-Type: {$response_mime_type}; charset=UTF-8");
print $sm->fetch("index.{$response_format}.tpl");
示例#12
0
 // already URL encoded
 $location = $_POST['location'];
 // user friendly display name of user location
 if ($location != "") {
     $location = urlencode($location);
     $place_name = urldecode($location);
     // geocode
     try {
         $location_XML = yahoo_geo($_REQUEST['location']);
         $location = $location_XML['Latitude'] . "," . $location_XML['Longitude'];
         $location_latitude = $location_XML['Latitude'];
         $location_longitude = $location_XML['Longitude'];
         // get event number
         $event_index = $_POST['event_index'];
         if ($event_index > 0) {
             $conn = get_db_connection($db_user, $db_passwd, $db_name);
             $event_label = $event_index;
             $latitudes[$event_index] = $location_latitude;
             $longitudes[$event_index] = $location_longitude;
             $sql_result = save_vote($location_latitude, $location_longitude, $event_label);
             //
             $db_status_close = close_db_connection($conn);
         } else {
             $event_label = "";
         }
         //
         $map_click_X = $_POST['map_x'];
         $map_click_Y = $_POST['map_y'];
     } catch (exception $e) {
         $location_latitude = 0;
         $location_longitude = 0;
示例#13
0
<?php

require 'db.php';
$conn = get_db_connection();
if ($conn === false) {
    ?>
	<h1>Error connecting to database</h1>
	<?php 
    die;
}
/* GET READY */
/* PUT YOUR CODE HERE */
?>

<form method="post">
	<textarea name="content"></textarea>
	<input type="text" name="author" placeholder="Your Name" />
	<button type="submit">Submit Post</button>
</form>
示例#14
0
function createFormElements($report_elements)
{
    global $bDebug;
    if (!is_array($report_elements)) {
        return;
    }
    unset($form_elements);
    foreach ($report_elements as $key => $value) {
        $elemName = $key;
        $elemLabel = $value["label"];
        $elemType = $value["type"];
        //$arr_params = Array("dbLink"=>get_db_connection(), "bDebug"=>$bDebug );
        $arr_params = get_db_connection();
        $elemValuesFunction = $value["values_func"];
        if ($elemValuesFunction != NULL) {
            $elemValues = @call_user_func_array($elemValuesFunction, $arr_params);
            //log_err("elemValuesFunction : $elemValuesFunction");
        } else {
            $elemValues = $value["values"];
        }
        $elemDefault = $value["default"];
        $elemRequired = $value["required"];
        switch ($elemType) {
            case "date":
                $strControl = createDateControl("document._FRM", $elemName, $elemDefault, $elemRequired);
                break;
            case "select":
                $strControl = createSelect($elemName, $elemValues, $elemDefault, $script, $class_style);
                break;
            case "multiselect":
                $strControl = createMultipleSelect($elemName, $elemValues, $elemDefault, $script, $class_style);
                break;
            case "input":
                $strControl = createTextField($elemName, $elemValues, $elemLabel, $class);
                break;
            case "checkbox":
                $strControl = createCheckBox($elemName, $elemValues, $elemLabel, $elemDefault);
                break;
            default:
                $strControl = "cant create control, elem type {$elemType} undefined.";
                break;
        }
        $form_elements[] = array("label" => $elemLabel, "required" => $elemRequired, "control" => $strControl);
    }
    return $form_elements;
}
示例#15
0
function get_database($dbname)
{
    $conn = get_db_connection();
    return $conn->{$dbname};
}
 /**
  * Will attempt to save the current record.  Can throw exceptions, so please try() your save()
  * An INSERT will be performed if the primary key for $this is not already populated
  * An UPDATE will be performed otherwise
  * Various options will be available within the function --> still under construction(ie. sanitize,quote,includeEmpties,includeNulls)
  * @param string/array $listOfFields --> determines which fields are to be saved (single fieldname string or indexed array of fieldnames)
  * @return bool
  */
 public function save($listOfFields = "*")
 {
     //If user passes *, then we'll attempt to save all columns (except for the primary key(s)) to the database
     if ($listOfFields == '*') {
         $listOfFields = $this->GetListOfFields();
     } elseif (!is_array($listOfFields)) {
         $listOfFields = array((string) $listOfFields);
         //In the event that only a fieldname was passed as a parameter (instead of an array), then we'll turn it into an array so we can continue anyway
     }
     $db = get_db_connection();
     //Create an assoc array of all the values we're about to save
     $nameValuePairs = $this->GetFieldsAsAssocArray($listOfFields);
     //Will remove the fields that are supposed to be excluded, and will even sanitize the data.
     $field_values = array_values($nameValuePairs);
     $field_names = array_keys($nameValuePairs);
     if (DB_DRIVER == 'mysql') {
         array_unshift($field_values, $this->GetBoundParamTypeString($field_names));
     }
     $primaryKeyData = array();
     foreach ($this->PRIMARYKEY as $fieldName) {
         $primaryKeyData[$fieldName] = $this->{$fieldName};
     }
     $pkValues = array_values($primaryKeyData);
     $autoIncrementFieldName = $this->AUTOINCREMENT[0];
     $boolAllPrimaryKeysHaveValues = count(array_filter($primaryKeyData)) == count($this->PRIMARYKEY);
     $boolNoPrimaryKeysHaveValues = count(array_filter($primaryKeyData)) == 0;
     if (!$boolAllPrimaryKeysHaveValues && !$boolNoPrimaryKeysHaveValues) {
         throw new Exception('Not all primary keys have a value in "this" object.  Not sure if INSERT or UPDATE is required, and so program was aborted.');
     }
     $field_esc_pre = $this::CHAR_ESCAPE_FIELD_NAME_PRE;
     $field_esc_post = $this::CHAR_ESCAPE_FIELD_NAME_POST;
     if ($boolNoPrimaryKeysHaveValues) {
         //INSERT new record when this class's primary key property is empty
         $sql = "INSERT INTO {$field_esc_pre}{$this->TABLENAME}{$field_esc_post}" . " ({$field_esc_pre}" . implode("{$field_esc_post}, {$field_esc_pre}", $field_names) . "{$field_esc_post})" . ' VALUES (' . str_repeat('?,', count($field_names) - 1) . '?) ';
         //file_put_contents('c:/temp/phplog.txt',$sql);
         $rs = $db->query($sql, null, null, $field_values);
         if ($rs) {
             $this->{$autoIncrementFieldName} = $db->insertID();
             return true;
         } else {
             return false;
         }
     } else {
         $where = 'WHERE ' . implode('=? AND ', $primaryKeyData) . ' = ?';
         //UPDATE existing record based on this class's primary key
         $sql = "UPDATE {$field_esc_pre}{$this->TABLENAME}{$field_esc_post} SET " . "{$field_esc_pre}" . implode("{$field_esc_post}=?, {$field_esc_pre}", $field_names) . "{$field_esc_post}=? " . "   {$where}";
         if (DB_DRIVER == 'mysql') {
             $field_values[0] = $field_values[0] . $this->GetBoundParamTypeString($this->PRIMARYKEY);
         }
         //Since we're about to add PRIMARYKEY's values ($pkValues), we'll need to append their 'iissdd'
         $field_values = array_merge($field_values, $pkValues);
         $rs = $db->query($sql, null, null, $field_values);
         if ($rs) {
             if (count($this->{$autoIncrementFieldName})) {
                 //If an auto-incrementing field exists in this table
                 $this->{$autoIncrementFieldName} = $db->insertID();
                 //Then set it equal to the newly generated ID
             }
             return true;
         } else {
             return false;
         }
     }
 }
示例#17
0
<?php

error_reporting(E_ALL);
session_start();
define('WEB', "http://localhost/photoAlbum/");
define('UPLOAD', WEB . 'files/');
define('INC', WEB . 'inc/');
define('ROOT', realpath(dirname(__FILE__)) . '/');
define('APP', ROOT . 'app/');
define('MODELS', ROOT . 'models/');
define('CONTROLLERS', ROOT . 'controllers/');
define('VIEWS', ROOT . 'views/');
require APP . "db.php";
get_db_connection()->query("set names UTF-8");
$queryString = $_SERVER['REQUEST_URI'];
$qmPos = strpos($queryString, '?');
if ($qmPos != 0) {
    $queryString = substr($queryString, 0, $qmPos);
}
$tmp = explode('/', $queryString);
$tmp = array_filter($tmp);
array_shift($tmp);
$queryString = implode('/', $tmp);
switch (true) {
    case empty($queryString):
        $controller = 'index';
        $action = 'index';
        $params = array();
        break;
    case preg_match('/^photos\\/(\\d+)$/', $queryString, $matches):
        $controller = 'photos';
示例#18
0
<?php

require_once "lib/ebpls.lib.php";
require_once "lib/ebpls.utils.php";
require_once "ebpls-php-lib/utils/ebpls.search.funcs.php";
//require_once("includes/eBPLS_header.php");
//--- get connection from DB
$dbLink = get_db_connection();
?>

<?php 
echo date("F dS Y h:i:s A");
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta http-equiv="Content-Type"
 content="text/html; charset=iso-8859-1">
  <title>MATERLIST OF PROFESSIONAL TAX</title>
  <meta name="Author" content=" Pagoda, Ltd. ">
  <link href="includes/eBPLS.css" rel="stylesheet" type="text/css">
  <script language="JavaScript" src="includes/eBPLS.js"></script>
</head>
<body>

<?php 
$result = mysql_query("select lgumunicipality, lguprovince, lguoffice from ebpls_buss_preference") or die(mysql_error());
$resulta = mysql_fetch_row($result);
?>
示例#19
0
function get_dm_db_connection()
{
    global $DB_CONFIGS;
    return get_db_connection($DB_CONFIGS['DM_DB_CREDS']);
}
示例#20
0
function print_ctc_form($type, $form_elem_values)
{
    $dbLink = get_db_connection();
    $is_ctc_renew = false;
    $ctcDebug = false;
    $is_ctc_renew = true;
    $clsCTC = new EBPLSCTC($dbLink, $ctcDebug);
    if ($type == "") {
        $type = CTC_TYPE_INDIVIDUAL;
    }
    //--- make a script that will calculate the tax
    //$ctc_additional_tax1_due=((int)($ctc_addtional_tax1)/1000));
    $tax_a1_fields = array("in" => array("document._FRM.ctc_additional_tax1"), "out" => "document._FRM.ctc_additional_tax1_due");
    $tax_a2_fields = array("in" => array("document._FRM.ctc_additional_tax2"), "out" => "document._FRM.ctc_additional_tax2_due");
    if ($type == CTC_TYPE_INDIVIDUAL) {
        $tax_a3_fields = array("in" => array("document._FRM.ctc_additional_tax3"), "out" => "document._FRM.ctc_additional_tax3_due");
        $basic_tax_field = array("in" => array('document._FRM.ctc_tax_exempted'), "out" => 'document._FRM.ctc_basic_tax');
        $out_total_interest_due = array("in" => array("x1" => 'document._FRM.current_month', "x2" => 'document._FRM.ctc_total_amount_due'), "out" => 'document._FRM.ctc_total_interest_due');
        $out_total_amount_due = array("in" => array("x1" => 'document._FRM.ctc_basic_tax', "x2" => 'document._FRM.ctc_additional_tax1_due', "x3" => 'document._FRM.ctc_additional_tax2_due', "x4" => 'document._FRM.ctc_additional_tax3_due'), "out" => 'document._FRM.ctc_total_amount_due');
        $out_total_paid_due = array("in" => array("x1" => 'document._FRM.ctc_total_amount_due', "x2" => 'document._FRM.ctc_total_interest_due'), "out" => 'document._FRM.ctc_total_paid');
    } else {
        $basic_tax_field = array("in" => NULL, "out" => 'document._FRM.ctc_basic_tax');
        $out_total_interest_due = array("in" => array("x1" => 'document._FRM.current_month', "x2" => 'document._FRM.ctc_total_amount_due'), "out" => 'document._FRM.ctc_total_interest_due');
        $out_total_amount_due = array("in" => array("x1" => 'document._FRM.ctc_basic_tax', "x2" => 'document._FRM.ctc_additional_tax1_due', "x3" => 'document._FRM.ctc_additional_tax2_due'), "out" => 'document._FRM.ctc_total_amount_due');
        $out_total_paid_due = array("in" => array("x1" => 'document._FRM.ctc_total_amount_due', "x2" => 'document._FRM.ctc_total_interest_due'), "out" => 'document._FRM.ctc_total_paid');
    }
    ?>
<P><BR>
<script language=Javascript>

function checkCitizenship() {

	if ( document._FRM.ctc_citizenship.selectedIndex > 1 ) {

		document._FRM.ctc_icr_no.disabled = false;

	} else {

		document._FRM.ctc_icr_no.disabled = true;
		document._FRM.ctc_icr_no.value = '';

	}

}

//--- start CTC application page scripts
function validate_ctc_form_application()
{

		var _FRM = document._FRM
		var msgTitle = "Community Tax Certificate Application\n";

		if ( _FRM.ctc_type.value == 'INDIVIDUAL' ) {


				if( isBlank(_FRM.ctc_last_name.value) == true)
				{
					alert( msgTitle + "Please input a valid lastname!");
					_FRM.ctc_last_name.focus();
					return false;
				}


				if( isBlank(_FRM.ctc_first_name.value) == true)
				{
					alert( msgTitle + "Please input a valid firstname!");
					_FRM.ctc_first_name.focus();
					return false;
				}

				if( isBlank(_FRM.ctc_middle_name.value) == true)
				{
					alert( msgTitle + "Please input a valid middlename!");
					_FRM.ctc_middle_name.focus();
					return false;
				}

				if( isBlank(_FRM.ctc_address.value) == true)
				{
					alert( msgTitle + "Please input a valid address!");
					_FRM.ctc_address.focus();
					return false;
				}

				if( _FRM.ctc_gender.selectedIndex == 0 )
				{
					alert( msgTitle + "Please input a valid gender!");
					_FRM.ctc_gender.focus();
					return false;
				}

				if( _FRM.ctc_citizenship.selectedIndex == 0 )
				{
					alert( msgTitle + "Please input a valid citizenship!");
					_FRM.ctc_citizenship.focus();
					return false;
				}

				if( _FRM.ctc_citizenship.item(_FRM.ctc_citizenship.selectedIndex).value != 'FILIPINO' && _FRM.ctc_icr_no.value == '' )
				{
					alert( msgTitle + "Please input a valid ICR No.!");
					_FRM.ctc_icr_no.focus();
					return false;
				}

				if( isBlank(_FRM.ctc_place_of_birth.value) == true)
				{
					alert( msgTitle + "Please input a valid place of birth!");
					_FRM.ctc_place_of_birth.focus();
					return false;
				}

				if( _FRM.ctc_civil_status.selectedIndex == 0 )
				{
					alert( msgTitle + "Please input a valid Civil Status!");
					_FRM.ctc_civil_status.focus();
					return false;
				}

				if( _FRM.ctc_birth_date.value == '' )
				{
					alert( msgTitle + "Please input a valid birthdate!");
					_FRM.ctc_birth_date_month.focus();
					return false;
				}

				//alert(_FRM.ctc_birth_date.value);

				if(  isBlank(_FRM.ctc_additional_tax1.value) == true && isBlank(_FRM.ctc_additional_tax2.value) == true && isBlank(_FRM.ctc_additional_tax3.value) == true )
				{
					alert( msgTitle + "Please input a valid last gross!");
					_FRM.ctc_additional_tax1.focus();
					return false;
				}

				if(  !isDigit(_FRM.ctc_additional_tax1.value) || !isDigit(_FRM.ctc_additional_tax2.value) && !isDigit(_FRM.ctc_additional_tax3.value) )
				{
					alert( msgTitle + "Please input a valid last gross!");
					_FRM.ctc_additional_tax1.focus();
					return false;
				}

				/*
				if(  !parseInt(_FRM.ctc_additional_tax1.value) && !parseInt(_FRM.ctc_additional_tax2.value) && !parseInt(_FRM.ctc_additional_tax3.value) )
				{
					alert( msgTitle + "Please input a valid last gross!");
					_FRM.ctc_additional_tax1.focus();
					return false;
				}
				*/

				if ( isBlank(_FRM.ctc_additional_tax1.value) ) {
					_FRM.ctc_additional_tax1.value = 0.0;
				}

				if ( isBlank(_FRM.ctc_additional_tax2.value) ) {
					_FRM.ctc_additional_tax2.value = 0.0;
				}

				if ( isBlank(_FRM.ctc_additional_tax3.value) ) {
					_FRM.ctc_additional_tax3.value = 0.0;
				}


		} else if ( _FRM.ctc_type.value = 'BUSINESS' ) {

			if( isBlank(_FRM.ctc_company.value) == true)
			{
				alert( msgTitle + "Please input a valid Company name!");
				_FRM.ctc_company.focus();
				return false;
			}

			if( isBlank(_FRM.ctc_tin_no.value) == true)
			{
				alert( msgTitle + "Please input a valid Company Tin No.!");
				_FRM.ctc_tin_no.focus();
				return false;
			}

			if( isBlank(_FRM.ctc_company_address.value) == true)
			{
				alert( msgTitle + "Please input a valid Company Addres!");
				_FRM.ctc_company_address.focus();
				return false;
			}


			if( _FRM.ctc_organization_type.selectedIndex == 0 )
			{
				alert( msgTitle + "Please input a valid Oraganization Type!");
				_FRM.ctc_organization_type.focus();
				return false;
			}

			if( _FRM.ctc_place_of_incorporation.value == '' )
			{
				alert( msgTitle + "Please input a valid place Of incorporation!");
				_FRM.ctc_place_of_incorporation.focus();
				return false;
			}

			if( _FRM.ctc_incorporation_date.value == '' )
			{
				alert( msgTitle + "Please input a valid Incorporation Date!");
				_FRM.ctc_incorporation_date_month.focus();
				return false;
			}

			if( isBlank(_FRM.ctc_business_nature.value) == true)
			{
				alert( msgTitle + "Please input a valid Business nature!");
				_FRM.ctc_business_nature.focus();
				return false;
			}

			if(  isBlank(_FRM.ctc_additional_tax1.value) == true && isBlank(_FRM.ctc_additional_tax2.value) == true )
			{
				alert( msgTitle + "Please input a valid last gross!");
				_FRM.ctc_additional_tax1.focus();
				return false;
			}

			// check if nonzero
			/*
			if(  !parseInt(_FRM.ctc_additional_tax1.value) && !parseInt(_FRM.ctc_additional_tax2.value) )
			{
				alert( msgTitle + "Please input a valid last gross!");
				_FRM.ctc_additional_tax1.focus();
				return false;
			}
			*/

			// check if a digit
			if(  !isDigit(_FRM.ctc_additional_tax1.value) || !isDigit(_FRM.ctc_additional_tax2.value) )
			{
				alert( msgTitle + "Please input a valid last gross!");
				_FRM.ctc_additional_tax1.focus();
				return false;
			}

			if ( isBlank(_FRM.ctc_additional_tax1.value) ) {
				_FRM.ctc_additional_tax1.value = 0.0;
			}

			if ( isBlank(_FRM.ctc_additional_tax2.value) ) {
				_FRM.ctc_additional_tax2.value = 0.0;
			}

		} else {

			alert('System Error : Invalid CTC Type ' + _FRM.ctc_type.value );

		}

	return true;
}



</script>

<form name="_FRM" method="POST" action="index.php?part=4&itemID_=101&class_type=CTC&busItem=CTC"  onSubmit="return validate_ctc_form_application();">
<!--<form name="_FRM" method="POST" action="<?php 
    echo getURI(eBPLS_PAGE_CTC_CRITERIA);
    ?>
"  onSubmit="return validate_ctc_form_application();">-->
<input type=hidden name="ctc_type" value="<?php 
    echo $ctc_type;
    ?>
">
<input type=hidden name="ctc_place_issued" value="<?php 
    echo get_ctc_place_issued();
    ?>
">
<input type=hidden name="cmd" value="<?php 
    echo CTC_CMD_PROCESS;
    ?>
">
<input type=hidden name="current_month" value="<?php 
    echo date("m");
    ?>
">
<?php 
    if ($type == CTC_TYPE_INDIVIDUAL) {
        echo "<input type=hidden name=\"ctc_owner_id\" value=\"" . $form_elem_values["ctc_owner_id"] . "\">";
        process_form_template("templates/form_ctc_individual_application.html", $form_elem_values);
    } else {
        echo "<input type=hidden name=\"ctc_business_id\" value=\"" . $form_elem_values["ctc_business_id"] . "\">";
        process_form_template("templates/form_ctc_business_application.html", $form_elem_values);
    }
    ?>
<P align=center>
<?php 
    /*
    if ( $type == CTC_TYPE_INDIVIDUAL ) {
    	echo "<input type=button value=\"Search Owner\"  onClick=\"javascript:showSearchForm('OWNER');\">";
    }else{
    	echo "<input type=button value=\"Search Business\" onClick=\"javascript:showSearchForm('BUSINESS');\">";
    }
    */
    ?>
&nbsp;&nbsp;<input type=submit value="Process Payment">&nbsp;&nbsp;<input type=reset value="Clear">
</p>
</form>
<script language="Javascript">

function showSearchForm( val ) {

	if ( val == 'OWNER' ) {

		popwin('owner_search.php','_OWNER_SEARCH');

	} else if ( val == 'BUSINESS' ) {

		popwin('business_search.php','_BUSINESS_SEARCH');

	} else {

		alert('invalid ctc search param');

	}

}

</script>
<?php 
    $clsCTC->printIndividualCTCScript($type, $basic_tax_field, $tax_a1_fields, $tax_a2_fields, $tax_a3_fields, $out_total_amount_due, $out_total_interest_due, $out_total_paid_due);
}
 /**
  * @param $primary_key string - column name you wish to count
  * @param $from string - table(s) name(s) used for the from statement
  * @param $join string - any join statement needed
  * @param $where string - where if you need to customize the stmt
  * @param $distinct boolean - determines if you want to count the number of distinct values of the primary key
  * @return int - returns filtered total number of rows for the sql (added where statement)
  * @throws CoreDBException
  * @author David Leonard
  */
 public function getTableListFilteredTotal($primary_key, $from, $join = "", $addWhere = "", $distinct = true)
 {
     $where = "";
     if ($addWhere == "") {
         if ($this->search != "") {
             $where = ' AND ' . $this->search;
         }
     } else {
         $where = $addWhere;
         if ($this->search != "") {
             $where .= ' AND (' . $this->search . ') ';
         }
     }
     $db = get_db_connection();
     if ($distinct) {
         $sql = 'SELECT COUNT(DISTINCT ' . $primary_key . ') AS count FROM ' . $from . ' ' . $join . ' WHERE 1=1 ' . $where;
     } else {
         $sql = 'SELECT COUNT(' . $primary_key . ') AS count FROM ' . $from . ' ' . $join . ' WHERE 1=1 ' . $where;
     }
     $rs = $db->query($sql);
     if ($rs) {
         $row = $rs->fetch(CoreDB::FETCH_ASSOC);
         return $row['count'];
     } else {
         return 0;
     }
 }
$g_debug_level = WARN;
// set the default logging level
// Set up some global variables for event data.
$g_event_keys = array('bounce' => array('smtp-id', 'reason', 'status', 'type'), 'click' => array('useragent', 'url', 'url_offset'), 'deferred' => array('smtp-id', 'attempt', 'response'), 'delivered' => array('smtp-id', 'response'), 'dropped' => array('smtp-id', 'reason'), 'open' => array('useragent'), 'processed' => array('smtp-id'), 'spamreport' => array('useragent'), 'unsubscribe' => array('useragent'));
$g_basic_keys = array('event', 'email', 'category', 'timestamp', 'sg_event_id', 'sg_message_id', 'ip', 'tls', 'cert_err');
$g_unique_keys = array('mailing_id', 'job_id', 'is_test', 'queue_id', 'instance', 'install_class', 'servername');
// Load up the configuration.
$config_path = realpath(dirname(__FILE__) . '/../config.ini');
$config = load_config($config_path);
if ($config === false) {
    reply_and_exit(HTTP_SRVERR);
}
// Set up the debug log level and log file, and open db connection.
$g_debug_level = get_debug_level($config);
$g_log_file = get_log_file($config);
$dbcon = get_db_connection($config);
if ($dbcon === false) {
    reply_and_exit(HTTP_SRVERR);
}
if (isset($_SERVER['CONTENT_TYPE']) && strpos($_SERVER['CONTENT_TYPE'], 'application/json') !== false) {
    //Process the batched data, separated json objects by new lines
    $jsonData = file_get_contents("php://input");
    log_(DEBUG, "Incoming JSON data: {$jsonData}");
    $batchData = json_decode($jsonData, true);
    if ($batchData) {
        log_(INFO, "Processing batch of " . count($batchData) . " event record(s)");
        foreach ($batchData as $eventData) {
            $http_status = create_event($config, $eventData, $dbcon);
            if ($http_status == HTTP_SRVERR) {
                break;
            }