Exemplo n.º 1
0
} else {
    /* first check all the variables */
    $subnet = getSubnetDetailsById($request['subnetId']);
    $subnet['subnet'] = Transform2long($subnet['subnet']);
    $subnet = $subnet['subnet'] . "/" . $subnet['mask'];
    /* verify IP address and subnet */
    $validIP = VerifyIpAddress($request['ip_addr'], $subnet);
    if (!empty($validIP)) {
        die('<div class="alert alert alert-danger">' . $validIP . '</div>');
    }
    /* verify that it is not yet used */
    if (checkDuplicate($request['ip_addr'], $subnet)) {
        die('<div class="alert alert alert-danger">' . _('IP address') . ' ' . $request['ip_addr'] . ' ' . _('already in use') . '!<br>* ' . _('First available IP address is') . ' <b>' . Transform2long(getFirstAvailableIPAddress($request['subnet'])) . '</a>!</div>');
    }
    /* verify that it is not yet used */
    if (checkDuplicate($request['ip_addr'], $request['subnetId'])) {
        die('<div class="alert alert alert-danger">' . _('IP address') . ' ' . $request['ip_addr'] . ' ' . _('already in use') . '!<br>* ' . _('First available IP address is') . ' <b>' . Transform2long(getFirstAvailableIPAddress($request['subnetId'])) . '</a>!</div>');
    }
    /* transform IP address */
    $request['ip_addr'] = Transform2decimal($request['ip_addr']);
    if (!acceptIPrequest($request)) {
        die('<div class="alert alert alert-danger">' . _('Cannot confirm IP address') . '!</div>');
        updateLogTable('Cannot confirm IP address!', 'Cannot accept IP request for request id ' . Transform2long($request['requestId']) . '!', 2);
    } else {
        print '<div class="alert alert-success">' . _('IP address request confirmed and added to database') . '!</div>';
        updateLogTable('IP address request confirmed and added to database!', 'IP request id ' . $request['requestId'] . ' (' . Transform2long($request['ip_addr']) . ') has been accepted!', 0);
    }
}
/* send email */
$subnet = getSubnetDetailsById($request['subnetId']);
$subnet['subnet'] = Transform2long($subnet['subnet']);
# verify post
CheckReferrer();
# ok, lets get results form post array!
foreach ($_POST as $key => $line) {
    // IP address
    if (substr($key, 0, 2) == "ip") {
        $res[substr($key, 2)]['ip_addr'] = $line;
    }
    // description
    if (substr($key, 0, 11) == "description") {
        $res[substr($key, 11)]['description'] = $line;
    }
    // dns name
    if (substr($key, 0, 8) == "dns_name") {
        $res[substr($key, 8)]['dns_name'] = $line;
    }
    //verify that it is not already in table!
    if (substr($key, 0, 2) == "ip") {
        if (checkDuplicate($line, $_POST['subnetId']) == true) {
            die("<div class='alert alert-danger'>IP address {$line} already exists!</div>");
        }
    }
}
# insert entries
if (sizeof($res) > 0) {
    if (insertScanResults($res, $_POST['subnetId'])) {
        print "<div class='alert alert-success'>" . _("Scan results added to database") . "!</div>";
    }
} else {
    print "<div class='alert alert-danger'>" . _("Error") . "</div>";
}
Exemplo n.º 3
0
    // {
    // 	$rptrOrg = mysqli_real_escape_string($con, $_POST['rptrOrgPri']);
    // }
    $rptrState = mysqli_real_escape_string($con, $_POST['rptrState']);
    $rptrOrg = mysqli_real_escape_string($con, $_POST['rptrOrg']);
    $rptrAddrs = mysqli_real_escape_string($con, $_POST['rptrAddrs']);
    $rptrDept = mysqli_real_escape_string($con, $_POST['rptrDept']);
    $rptrCntct = mysqli_real_escape_string($con, $_POST['rptrCntct']);
    $rptrEmail = mysqli_real_escape_string($con, $_POST['rptrEmail']);
    $rptrDateofRpt = mysqli_real_escape_string($con, $_POST['rptrDateofRpt']);
    $rptrDateofRpt = dateConverter($rptrDateofRpt);
    $rptVerName = mysqli_real_escape_string($con, $_POST['rptVerName']);
    $rptrVerDesig = mysqli_real_escape_string($con, $_POST['rptrVerDesig']);
    $rptrCmt = mysqli_real_escape_string($con, $_POST['rptrCmt']);
    $delQuery = "DELETE FROM adrdata WHERE adrFormID = {$formID}";
    $query = "INSERT INTO adrdata\n\t(adrDataIDAI, adrFormID, Adrno, Madracno, CCIN, Source, \n\t\tState, Inst, report_type, age, age_unit, age_group, \n\t\twt, sex, ethnic, race, onset_date, date_end_reaction, \n\t\tonset_time, onset_time_unit, extent, notes, atccode, outcome, \n\t\treaction_subsided, reaction_reappeared, reaction_treatment, date_of_death, death_code, reaction_relation, \n\t\tlab_data, history, historyCont, `status`, \n\t\treporter_name, reporter_dept, report_date, reporter_faxno, reporter_comment, reporter_org, \n\t\treporter_telno, reporter_email, reporter_address, reporter_state, madrac_action, total_drugs, \n\t\tdechall, rechall, causality1, causality2, pred_code, add_info, \n\t\trep_who, adr_type, icdcode, adr_desc, initial, madrac, \n\t\tweb_hosp, desig, partbody, literature_ref, study_name, lastMenDate, \n\t\tgesPer, gesPerUnit, weight, height, seriousness, seriousnessCrit, \n\t\trt1stTime, rt1stTimeUnit, rtLastTime, rtLastTimeUnit, causeOfDeath, autopsyYesNo, \n\t\tautopsyText, report_comment, ADR_ORIGIN, ADR_CURRENTSTAT, senderIden, dateRcv, \n\t\tstudy_type, study_type_otr, reportInit, pregnancyStat, allergyStat, allergyText,\n\t\tcaseType, ptDOB, rptVerName, rptrVerDesig,\n\t\tchInitial, chAge, chAgeUnit, chAgeGrp, chSex,\n\t\tprimRptrQuali, primRptrName, primRptrDesig, primRptrState, primRptrOrg, primRptrDept, primRptrAddrs,\n\t\tinitRptNum, log_id)\nVALUES (NULL, {$formID}, '{$adrNo}', '{$madracno}', '', {$primSource}, \n\t\t'', '', {$typeOfReport}, {$ptAge}, {$ptageUnit}, {$ptAgeGrp}, \n\t\t'', '{$sex}', '{$ethnic}', '', '', '', \n\t\t0, 0, '', '{$refNo}', '', '', \n\t\t'', '', '', '', '', '', \n\t\t'{$relInves}', '{$history}', {$historyCont}, '{$status}', \n\t\t'{$rptrName}', '{$rptrDept}', '{$rptrDateofRpt}', '', '', '{$rptrOrg}', \n\t\t'{$rptrCntct}', '{$rptrEmail}', '{$rptrAddrs}', '{$rptrState}', '', 0, \n\t\t'', '', '', '', '', '', \n\t\t'', '', '', '{$adrDesc}', '{$ptInitial}', '', \n\t\t'', '{$rptrDesig}', '', '{$litrRef}', '{$stdName}', '{$lastMenDate}', \n\t\t{$gesPer}, {$gesPerUnit}, {$weight}, {$height}, NULL, '', \n\t\t0, 0, 0, 0, '', 0, \n\t\t'', '{$rptrCmt}', '', '', '{$senderIden}', '{$dateRptRcv}', \n\t\t'{$studyType}', '{$studyTypeOtr}', {$reportInit}, {$pregnancyStat}, {$allergyStat}, '{$allergyText}',\n\t\t{$caseType}, '{$ptDOB}', '{$rptVerName}', '{$rptrVerDesig}',\n\t\t'{$chInitial}', {$chAge}, {$chAgeUnit}, {$chAgeGrp}, '{$chSex}',\n\t\t{$primRptrQuali}, '{$primRptrName}', '{$primRptrDesig}', '{$primRptrState}', '{$primRptrOrg}', '{$primRptrDept}', '{$primRptrAddrs}',\n\t\t'{$initRptNum}', '{$staff_id}')";
    // $log = " $query ".time().PHP_EOL;
    // file_put_contents('log.txt', $log, FILE_APPEND);
    $dupStat = checkDuplicate($formID);
    $delRes = mysqli_query($con, $delQuery);
    $res = mysqli_query($con, $query);
    if ($res) {
        $log = "Form: {$formID} submitted " . time() . PHP_EOL;
        file_put_contents('log.txt', $log, FILE_APPEND);
        header("Location: submit_adr_view_res.php?vtype={$retURLParam}");
    } else {
        echo "Error Submitting Form: " . mysqli_error($con);
        $log = " {$query} " . PHP_EOL . $query;
        file_put_contents('log.txt', $log, FILE_APPEND);
    }
}
Exemplo n.º 4
0
/**
 * CSV import IP address
 *
 *		provided input is CSV line!
 */
function importCSVline($line, $subnetId)
{
    global $database;
    /* get subnet details by Id */
    $subnetDetails = getSubnetDetailsById($subnetId);
    $subnet = Transform2long($subnetDetails['subnet']) . "/" . $subnetDetails['mask'];
    /* verify! */
    $err = VerifyIpAddress($line[0], $subnet);
    if ($err) {
        return _('Wrong IP address') . ' - ' . $err . ' - ' . $line[0];
    }
    /* check for duplicates */
    if (checkDuplicate($line[0], $subnetId)) {
        return _('IP address already exists') . ' - ' . $line[0];
    }
    /* get custom fields */
    $myFields = getCustomFields('ipaddresses');
    if (sizeof($myFields) > 0) {
        $import['fieldName'] = "";
        $import['fieldValue'] = "";
        $m = 9;
        foreach ($myFields as $field) {
            //escape chars
            $line[$m] = mysqli_real_escape_string($database, $line[$m]);
            $import['fieldName'] .= ",`{$field['name']}`";
            $import['fieldValue'] .= ",'{$line[$m]}'";
            $m++;
        }
    }
    /* escape chars */
    foreach ($line as $k => $l) {
        $line[$k] = mysqli_real_escape_string($database, $l);
    }
    /* all ok, set query */
    $query = "insert into ipaddresses ";
    $query .= "(`subnetId`, `ip_addr`, `state`, `description`, `dns_name`, `mac`, `owner`, `switch`, `port`, `note` {$import['fieldName']} ) ";
    $query .= "values ";
    $query .= "('{$subnetId}','" . Transform2decimal($line[0]) . "', '{$line['1']}','{$line['2']}','{$line['3']}','{$line['4']}','{$line['5']}','{$line['6']}','{$line['7']}','{$line['8']}' {$import['fieldValue']});";
    /*
    	print "<pre>";
    	print_r($line);
    	die('alert alert-danger');
    */
    /* set log details */
    $log = prepareLogFromArray($line);
    /* execute */
    try {
        $database->executeQuery($query);
    } catch (Exception $e) {
        $error = $e->getMessage();
    }
    if (!isset($e)) {
        updateLogTable('CSV import of IP address ' . $line[1] . ' succeeded', $log, 0);
        return true;
    } else {
        updateLogTable('CSV import of IP address ' . $line[1] . ' failed', $log, 2);
        return $error;
    }
}
if ($subnetPerm < 2) {
    die('<div class="alert alert-error">' . _('You do not have permissions to modify hosts in this subnet') . '!</div>');
}
# verify post */
CheckReferrer();
# get subnet details
$subnet = getSubnetDetailsById($_POST['subnetId']);
# get all existing IP addresses
$addresses = getIpAddressesBySubnetId($_POST['subnetId']);
# set start and end IP address
$calc = calculateSubnetDetailsNew($subnet['subnet'], $subnet['mask'], 0, 0, 0, 0);
$max = $calc['maxhosts'];
# loop and get all IP addresses for ping
for ($m = 1; $m <= $max; $m++) {
    // create array of IP addresses (if they do not already exist!)
    if (!checkDuplicate(transform2long($subnet['subnet'] + $m), $_POST['subnetId'])) {
        $ip[] = $subnet['subnet'] + $m;
    }
}
# create 1 line for $argv
// <eNovance>
// Print a message if no host is found then exit
if (count($ip) == 0) {
    print "<div class='alert alert-info'>All host already listed</div>";
    exit;
}
// </eNovance>
$ip = implode(";", $ip);
# get php exec path
$phpPath = getPHPExecutableFromPath();
# set script
 if (isset($_POST['csv_format_column'])) {
     $validate = true;
     switch ($_POST['csv_format_type_id']) {
         case 1:
             $validate = $validate && checkNecessity($_POST['csv_format_column'], $ProductCSV->getFormatColumns($_POST['csv_format_type_id']));
             $validate = $validate && checkDuplicate($_POST['csv_format_column'], $ProductCSV->getFormatColumns($_POST['csv_format_type_id']), $ProductCSV->getFormatColumnIgnore($_POST['csv_format_type_id']));
             break;
         case 2:
             $validate = $validate && checkNecessity($_POST['csv_format_column'], $ProductCSV->getFormatColumns($_POST['csv_format_type_id']));
             $validate = $validate && checkDuplicate($_POST['csv_format_column'], $ProductCSV->getFormatColumns($_POST['csv_format_type_id']), $ProductCSV->getFormatColumnIgnore($_POST['csv_format_type_id']));
             $validate = $validate && checkSequential($_POST['csv_format_column'], $ProductCSV->getFormatColumns($_POST['csv_format_type_id']));
             $validate = $validate && checkDepth($_POST['csv_format_column'], $ProductCSV->getFormatColumns($_POST['csv_format_type_id']));
             break;
         case 3:
             $validate = $validate && checkNecessityOption($_POST['csv_format_column'], $ProductCSV->getFormatColumns($_POST['csv_format_type_id']));
             $validate = $validate && checkDuplicate($_POST['csv_format_column'], $ProductCSV->getFormatColumns($_POST['csv_format_type_id']), $ProductCSV->getFormatColumnIgnore($_POST['csv_format_type_id']));
             break;
     }
 }
 if (!isset($_POST['csv_format_column']) || $validate) {
     if (isset($_POST['fID'])) {
         $csv_format_id = $_POST['fID'];
     } else {
         $csv_format_id = false;
     }
     $ProductCSV->setFormat($_POST['csv_format_type_id'], $_POST['csv_format_name'], $_POST['csv_format_column'], $csv_format_id);
     if (isset($_SESSION['product_csv']['upfile'])) {
         unlink($_SESSION['product_csv']['upfile']);
         unset($_SESSION['product_csv']['upfile']);
     }
     zen_redirect(zen_href_link(FILENAME_ADDON_MODULES_ADMIN, 'module=product_csv/csv_format'));
Exemplo n.º 7
0
        if ($ip['action'] == "add") {
            if (checkDuplicate($ip['ip_addr'], $ip['subnetId'])) {
                die('<div class="alert alert-danger">' . _('IP address') . ' ' . $ip['ip_addr'] . ' ' . _('already existing in database') . '!</div>');
            }
        }
        /* check for duplicate entry on edit! */
        if ($ip['action'] == "edit") {
            # if IP is the same than it can already exist!
            if ($ip['ip_addr'] != $_REQUEST['ip_addr_old']) {
                if (checkDuplicate($ip['ip_addr'], $ip['subnetId'])) {
                    die('<div class="alert alert-danger">' . _('IP address') . ' ' . $ip['ip_addr'] . ' ' . _('already existing in database') . '!</div>');
                }
            }
        }
        /* move checks */
        if ($ip['action'] == "move") {
            # check if not already used in new subnet
            if (checkDuplicate($ip['ip_addr'], $ip['newSubnet'])) {
                die('<div class="alert alert-danger">' . _('Duplicate IP address') . ' ' . $ip['ip_addr'] . ' ' . _('already existing in selected network') . '!</div>');
            }
        }
        /* execute insert / update / delete query */
        if (!modifyIpAddress($ip)) {
            print '<div class="alert alert-danger">' . _('Error inserting IP address') . '!</div>';
            updateLogTable('Error ' . $ip['action'] . ' IP address ' . $ip['ip_addr'], 'Error ' . $ip['action'] . ' IP address ' . $ip['ip_addr'] . '<br>SubnetId: ' . $ip['subnetId'], 2);
        } else {
            print '<div class="alert alert-success">' . _("IP {$ip['action']} successful") . '!</div>';
            updateLogTable($ip['action'] . ' of IP address ' . $ip['ip_addr'] . ' succesfull!', $ip['action'] . ' of IP address ' . $ip['ip_addr'] . ' succesfull!<br>SubnetId: ' . $ip['subnetId'], 0);
        }
    }
}
Exemplo n.º 8
0
function updateRadioSection($section, $columnNo, $inpName, $row, $edit_kredi_id, $property, $property_id)
{
    $db2 =& JFactory::getDBO();
    $query2 = 'SELECT * FROM #__property_types where section="' . $section . '" order by id asc; ';
    $db2->setQuery($query2);
    $propTypes = $db2->loadObjectList();
    $propertyStartId = $propTypes[0]->id;
    $textArray = array("Görünüs", "Performans", "Fiyat", "Hiz", "Dayaniklilik", "Hatasizlik", "Erisim Maliyeti", "Erisim Kolayligi", "Bakim Maliyeti", "Bakim Kolayligi", "Kalitesi", "Termin", "CE Uyumlulugu");
    for ($i = 0; $i < count($textArray); $i++) {
        $duplicates = checkDuplicate($db2, $row->id, $property_id, $i + 1, $edit_kredi_id);
        if (!$duplicates) {
            // add new row
            $property->id = 0;
            // to insert a new row
            $property->kredi_id = $row->id;
            $property->lineNo = $i + 1;
            $property->property_value = $textArray[$i];
            $property->property_id = $property_id;
            $property->store();
        } else {
            // change only value
            $property =& JTable::getInstance('property_values', 'Table');
            $property->id = $duplicates[0]->id;
            $property->property_value = $textArray[$i];
            $property->store();
        }
    }
    if (isset($_POST['input' . $inpName])) {
        $manualFieldCount = count($_POST['input' . $inpName]);
    } else {
        $manualFieldCount = 0;
    }
    /*if(isset($_POST['input'.$inpName])){
    	$inputArray=$_POST['input'.$inpName];
    	for($i=0; $i<count($inputArray); $i++)
    	{
    		$duplicates = checkDuplicate($db2, $row->id, $property_id, $i+1, $edit_kredi_id);
    		
    		if(!$duplicates){// add new row
    			$property->id = 0; // to insert a new row
    			$property->kredi_id = $row->id;
    			$property->lineNo=($i+1+count($textArray));
    			$property->property_value=$inputArray[$i];
    			$property->property_id = $property_id;
    			$property->store();
    		}
    		else{// change only value
    			$property =& JTable::getInstance('property_values', 'Table');
    			$property->id = $duplicates[0]->id;
    			$property->property_value=$array[$i];
    			$property->store();
    		}
    	}
    }*/
    //BURADA 2. ve 3. kolonu tamamen alıyor
    for ($col = 1; $col < $columnNo; $col++) {
        //$array=$_POST['input'.$inpName.'-'.($col)];
        for ($i = 0; $i < count($textArray) + $manualFieldCount; $i++) {
            $duplicates = checkDuplicate($db2, $row->id, $propertyStartId + $col, $i + 1, $edit_kredi_id);
            if (!$duplicates) {
                // add new row
                $property->id = 0;
                // to insert a new row
                $property->kredi_id = $row->id;
                $property->lineNo = $i + 1;
                //$property->property_value=$array[$i];
                $property->property_value = $_POST['input' . $inpName . '-' . $col . '-' . ($i + 1)];
                $property->property_id = $propertyStartId + $col;
                if ($property->property_value != null) {
                    if (isset($_POST['input' . $inpName]) && $i >= count($textArray)) {
                        if ($_POST['input' . $inpName][$i - count($textArray)] != null) {
                            $property->store();
                        }
                    } else {
                        $property->store();
                    }
                }
            } else {
                // change only value
                $property =& JTable::getInstance('property_values', 'Table');
                $property->id = $duplicates[0]->id;
                $property->property_value = $_POST['input' . $inpName . '-' . $col . '-' . ($i + 1)];
                $property->store();
            }
        }
    }
    $lastLineNo = getLastLine($db2, $row->id, $propertyStartId);
    for ($i = 0; $i < $manualFieldCount; $i++) {
        $duplicates = checkDuplicate($db2, $row->id, $propertyStartId, count($textArray) + $i + 1, $edit_kredi_id);
        if (!$duplicates) {
            // add new row
            if ($_POST['input' . $inpName][$i] == null) {
                continue;
            }
            $property->id = 0;
            // to insert a new row
            $property->kredi_id = $row->id;
            $property->lineNo = ++$lastLineNo;
            //$property->property_value=$array[$i];
            $property->property_value = $_POST['input' . $inpName][$i];
            $property->property_id = $propertyStartId;
            $property->store();
        } else {
            // change only value
            $property =& JTable::getInstance('property_values', 'Table');
            $property->id = $duplicates[0]->id;
            $property->property_value = $_POST['input' . $inpName][$i];
            $property->store();
        }
    }
}
Exemplo n.º 9
0
/**
 * CSV import IP address
 *
 *		provided input is CSV line!
 */
function importCSVline($line, $subnetId)
{
    /* array */
    $line = explode(",", $line);
    global $db;
    # get variables from config file
    $database = new database($db['host'], $db['user'], $db['pass'], $db['name']);
    /* get subnet details by Id */
    $subnetDetails = getSubnetDetailsById($subnetId);
    $subnet = Transform2long($subnetDetails['subnet']) . "/" . $subnetDetails['mask'];
    /* verify! */
    if (VerifyIpAddress($line[0], $subnet)) {
        return _('Wrong IP address') . ' - ' . $line[0];
    }
    /* check for duplicates */
    if (checkDuplicate($line[0], $subnetId)) {
        return _('IP address already exists') . ' - ' . $line[0];
    }
    /* reformat state */
    switch ($line[5]) {
        case "Active":
            $line[5] = "1";
            break;
        case "active":
            $line[5] = "1";
            break;
        case "Reserved":
            $line[5] = "2";
            break;
        case "reserved":
            $line[5] = "2";
            break;
        case "Offline":
            $line[5] = "0";
            break;
        case "offline":
            $line[5] = "0";
            break;
    }
    /* reformat switch! */
    $switch = getSwitchDetailsByHostname($line[7]);
    /* get custom fields */
    $myFields = getCustomIPaddrFields();
    if (sizeof($myFields) > 0) {
        $import['fieldName'] = "";
        $import['fieldValue'] = "";
        $m = 9;
        foreach ($myFields as $field) {
            $import['fieldName'] .= ",`{$field['name']}`";
            $import['fieldValue'] .= ",'{$line[$m]}'";
            $m++;
        }
    }
    /* all ok, set query */
    $query = "insert into ipaddresses ";
    $query .= "(`subnetId`, `ip_addr`, `state`, `description`, `dns_name`, `mac`, `owner`, `switch`, `port`, `note` {$import['fieldName']} ) ";
    $query .= "values ";
    $query .= "('{$subnetId}','" . Transform2decimal($line[0]) . "', '{$line['1']}','{$line['2']}','{$line['3']}','{$line['4']}','{$line['5']}','{$line['6']}','{$switch['id']}','{$line['8']}' {$import['fieldValue']});";
    /* set log details */
    $log = prepareLogFromArray($line);
    /* execute */
    try {
        $database->executeQuery($query);
    } catch (Exception $e) {
        $error = $e->getMessage();
    }
    if (!isset($e)) {
        updateLogTable('CSV import of IP address ' . $line[1] . ' succeeded', $log, 0);
        return true;
    } else {
        updateLogTable('CSV import of IP address ' . $line[1] . ' failed', $log, 2);
        return $error;
    }
}