Example #1
0
$q = $db->select($sqltext, array($_GET['id']), 'i');
$r = $q[0];
$addsid = $r->addsid;
if (isset($_GET['remove']) && $_GET['remove'] == "y" && isset($_GET['id']) && is_numeric($_GET['id'])) {
    db_delete("contacts", $_GET['id'], 'contactsid');
    header("Location: /contacts/");
    exit;
}
if (isset($_GET['go']) && $_GET['go'] == "y") {
    // Add to Address table
    $addsid = db_updateAddress($_POST, $addsid);
    $contactsUpdate = new Contacts();
    // Update DB
    $contactsUpdate->setContactsid($_GET['id']);
    $contactsUpdate->setFname($_POST['fname']);
    $contactsUpdate->setSname($_POST['sname']);
    $contactsUpdate->setCo_name($_POST['co_name']);
    $contactsUpdate->setRole($_POST['role']);
    $contactsUpdate->setCustid($_POST['custid']);
    $contactsUpdate->setSuppid($_POST['suppid']);
    $contactsUpdate->setNotes($_POST['notes']);
    $contactsUpdate->updateDB();
    header("Location: /contacts/?Updated=" . $result['id']);
    exit;
}
$pagetitle = "Edit contact";
include "../tmpl/header.php";
if (isset($_GET['SentAccessEmail']) && $_GET['SentAccessEmail'] == 1) {
    ?>
<div class="panel panel-success">
	<div class="panel-heading">Sent an Email</div>
Example #2
0
$fields = array("fname", "sname", "co_name", "role", "notes", "custid", "suppid");
foreach ($fields as $field) {
    if (!isset($_POST[$field])) {
        $_POST[$field] = '';
    }
}
if (isset($_GET['go']) && $_GET['go'] == "y") {
    $logContent = "\n";
    $pw = generatePassword();
    // Add to Address table
    $addsid = db_addAddress($_POST);
    $logon = generateContactlogon($_POST['fname'], $_POST['sname']);
    // Insert into DB
    $contactsNew = new Contacts();
    $contactsNew->setFname($_POST['fname']);
    $contactsNew->setSname($_POST['sname']);
    $contactsNew->setCo_name($_POST['co_name']);
    $contactsNew->setRole($_POST['role']);
    $contactsNew->setCustid($_POST['custid']);
    $contactsNew->setSuppid($_POST['suppid']);
    $contactsNew->setAddsid($addsid);
    $contactsNew->setNotes($_POST['notes']);
    $contactId = $contactsNew->insertIntoDB();
    // Insert into DB
    $pwdNew = new Pwd();
    $pwdNew->setUsr($logon);
    $pwdNew->setContactsid($contactId);
    $pwdNew->setSeclev(100);
    $pwdNew->setPw(mkPwd($pw));
    file_put_contents('/etc/athenace/pwd', "{$_POST['custid']}\t{$_POST['suppid']}\t{$logon}\t{$pw}\n", FILE_APPEND);
    // Dont add to the Password table unless they have a custid or a suppid