function update_address($addressInfo) { if (!(isset($addressInfo['address_id']) && (isset($addressInfo['customer_id']) || isset($addressInfo['user_id'])))) { throw new Exception("ERROR: address_id and customer_id or user_id required"); } $oldInfo = get_addresses($addressInfo)[0]; //takes customer/user id and address id if (empty($oldInfo)) { throw new Exception("Could not find address id for customer or user."); } $addressInfo = array_replace($oldInfo, $addressInfo); $query = "UPDATE addresses SET name = :name, address1 = :address1, address2 = :address2, city = :city, state = :state, zipcode = :zipcode, type = :type WHERE id = :address_id"; $dbh = new PDOConnection(); $sth = $dbh->prepare($query); $sth->bindParam(':name', $addressInfo['name']); $sth->bindParam(':address1', $addressInfo['address1']); $sth->bindParam(':address2', $addressInfo['address2']); $sth->bindParam(':city', $addressInfo['city']); $sth->bindParam(':state', $addressInfo['state']); $sth->bindParam(':zipcode', $addressInfo['zipcode']); $sth->bindParam(':type', $addressInfo['type'], PDO::PARAM_INT); $sth->bindParam(':address_id', $addressInfo['address_id'], PDO::PARAM_INT); if (!$sth->execute()) { throw new Exception("ERROR: could not update address - " . $sth->errorInfo()[2]); } return $addressInfo; }
function put_addresses_for_person($personid) { if (NULL != ($Records = get_addresses(0, $personid))) { foreach ($Records as $Record) { ?> <div class='Person_content'> <?php put_Separating("home82.png", $Record['city']); put_field("placard_1.png", get_string_of_streets_from_address($Record)); put_field("locator7.png", $Record['location']); put_field("placeholder8.png", $Record['region']); put_field("flag11.png", $Record['country']); put_field("comments1.png", $Record['comments']); ?> </div> <?php } } }
function add_cart_header($cartHeader) { $dbh = new PDOConnection(); if (!(isset($cartHeader['user_id']) && $cartHeader['delivery_date'] && $cartHeader['delivery_method'])) { throw new Exception("Must provide user_id, delivery_date, and delivery_method"); } $user_id = $cartHeader['user_id']; if (check_cart_exists($dbh, $user_id)) { throw new Exception("User cart already exists"); } $delivery_date = $cartHeader['delivery_date']; $delivery_method = $cartHeader['delivery_method']; //optional parameters $shipping_type = isset($cartHeader['shipping_type']) ? $cartHeader['shipping_type'] : ''; $comments = isset($cartHeader['comments']) ? $cartHeader['comments'] : ''; $shipping_comments = isset($cartHeader['shipping_comments']) ? $cartHeader['shipping_comments'] : ''; $warehouse = isset($cartHeader['warehouse']) ? $cartHeader['warehouse'] : ''; //TODO: this $address_id = isset($cartHeader['address_id']) ? $cartHeader['address_id'] : NULL; //TODO: this //get address id from user/customers if (empty($address_id)) { $addresses = get_addresses(array('user_id' => $user_id, 'customer_id' => -1, 'type' => ADDRESS_TYPE_SHIP)); $address_id = isset($addresses[0]['address_id']) ? $addresses[0]['address_id'] : -1; //no address } $query = "INSERT INTO cart_headers(user_id, delivery_date, delivery_method, shipping_type, address_id, comments, shipping_comments, created) "; $query .= "VALUES(:user_id, :delivery_date, :delivery_method, :shipping_type, :address_id, :comments, :shipping_comments, now())"; $sth = $dbh->prepare($query); $sth->bindParam(':user_id', $user_id); $sth->bindParam(':delivery_date', $delivery_date); $sth->bindParam(':delivery_method', $delivery_method); $sth->bindParam(':shipping_type', $shipping_type); $sth->bindParam(':comments', $comments); $sth->bindParam(':shipping_comments', $shipping_comments); $sth->bindParam(':address_id', $address_id); if (!$sth->execute()) { throw new Exception($sth->errorInfo()[2]); } return true; }
function submit_order($values) { if (!(isset($values['user_id']) && isset($values['token']))) { throw new Exception('user_id and token required'); } if (FALSE === VerifyToken($values['token'], $values['user_id'], NULL)) { throw new Exception('Your session has expired. Please log in again.'); } //set up all data to be passed to add_order() $userInfo = get_users(array('id' => $values['user_id'])); $email = isset($values['email']) ? $values['email'] : $userInfo['email']; $dbh = new PDOConnection(); $order = get_cart_information($dbh, $values); //TODO : customer_id $billing_addresses = get_addresses(array('user_id' => $values['user_id'], 'customer_id' => -1, 'type' => ADDRESS_TYPE_BILL)); $order['billing_address_id'] = isset($billing_addresses[0]['address_id']) ? $billing_addresses[0]['address_id'] : $order['shipping_address_id']; $orderInfo = add_order($order); order_confirmation_email(array_merge($orderInfo, array('email' => $email))); //delete cart delete_cart_by_user_id($dbh, $values['user_id']); return $orderInfo; }
function send_email($emailSubject = "", $emailBody = "") { // Note these emails need to be Blind Carbon Coby $emailAddresses = get_addresses(); $headers = "From: " . TCSHL_EMAIL . "\n"; $headers .= "Bcc: {$emailAddresses}" . "\n"; //Send email mail('', $emailSubject, $emailBody, $headers); }
function make_vspherestat_summary($preloading = false) { $table = new CTableInfo(); $table->setHeader(array(is_show_all_nodes() ? S_NODE : null, _('Host name'), _('Interface'), _('CPU threads [used/total]'), _('Memory(GB) [used/total]'), _('Datastores'), _('PoweredOn'), _('Suspended'), _('PoweredOff'), _('Others'))); $hidden = new CDiv(null, "hidden"); $hidden->setAttribute("type", "hidden"); $script_itemkey = 'push_message.py[{$HYCLOPS_SERVER},{$HYCLOPS_PORT},vsphere,{HOST.HOST}]'; $hosts = get_vsphere_hosts(); if (empty($hosts)) { return null; } foreach ($hosts as $host) { if (!$preloading) { if (is_script_success($host['hostid'], $script_itemkey)) { $hardware_profiles = get_hardware_profiles($host['hostid']); $datastores = get_datastores($host['hostid']); $instances = get_instances($host['hostid']); $instances = filter_instances($instances); $r = new CRow(); // Host name $col = new CCol($host['host'], 'vsphere'); $col->setAttribute("hostid", $host['hostid']); $r->addItem($col); // IP $snmp_addresses = get_addresses($host['hostid'], INTERFACE_TYPE_SNMP); $r->addItem(reset($snmp_addresses)); // CPU thread $r->addItem(level_check($hardware_profiles['cpu_assigned'], $hardware_profiles['cpu'])); // Memory $r->addItem(level_check($hardware_profiles['memory_assigned'], $hardware_profiles['memory'])); // Datastores $datastores_count = new CSpan(count($datastores), 'pointer'); if (!empty($datastores)) { $datastores_count->setHint(make_datastore_table($host['hostid'], $datastores)); } $r->addItem(new CCol($datastores_count)); // PowerOn $poweron_vms = $instances["running"]; $poweron_count = new CSpan(count($poweron_vms), 'pointer'); if (!empty($poweron_vms)) { $poweron_count->setHint(make_vm_table('poweron', $poweron_vms)); } $r->addItem(new CCol($poweron_count)); // Suspended $suspend_vms = $instances["pending"]; $suspend_count = new CSpan(count($suspend_vms), 'pointer'); if (!empty($suspend_vms)) { $suspend_count->setHint(make_vm_table('suspend', $suspend_vms)); } $r->addItem(new CCol($suspend_count)); // PowerOff $poweroff_vms = $instances["stopped"]; $poweroff_count = new CSpan(count($poweroff_vms), 'pointer'); if (!empty($poweroff_vms)) { $poweroff_count->setHint(make_vm_table('poweroff', $poweroff_vms)); } $r->addItem(new CCol($poweroff_count)); // Other $other_vms = $instances["other"]; $other_count = new CSpan(count($other_vms), 'pointer'); if (!empty($other_vms)) { $other_count->setHint(make_vm_table('other', $other_vms)); } $other_state_col = new CCol($other_count, count($other_vms) > 0 ? 'high' : null); $r->addItem($other_state_col); $table->addRow($r); zbx_add_post_js('chkbxRange.pageGoName = "vms";'); } else { $snmp_addresses = get_addresses($host['hostid'], INTERFACE_TYPE_SNMP); $r = new CRow(); $r->addItem($host['host']); $r->addItem(reset($snmp_addresses)); $r->addItem(new CCol(_('script failed'), "high")); $r->addItem(array("-", "-", "-", "-", "-", "-")); $table->addRow($r); } } else { // display loading message $snmp_addresses = get_addresses($host['hostid'], INTERFACE_TYPE_SNMP); $r = new CRow(); $r->addItem($host['host']); $r->addItem(reset($snmp_addresses)); $r->addItem(_('loading...')); $r->addItem(array("-", "-", "-", "-", "-", "-")); $table->addRow($r); } } #insert_js('init_vsphere_contextmenu()'); $script = new CJSScript(get_js("jQuery('#hat_vspherestat_footer').html('" . _s('Updated: %s', zbx_date2str(_('H:i:s'))) . "')")); return new CDiv(array($table, $script)); }
} elseif (isset($_GET['function'])) { $function = $_GET['function']; $values = $_GET; } else { $values = (array) json_decode(file_get_contents('php://input')); $function = $values['function']; } switch ($function) { case 'add_address': include_once __DIR__ . '/customers/add_address.php'; $responseArray['response'] = add_address($values); $responseArray['message'] = 'Address added'; break; case 'get_addresses': include_once __DIR__ . '/customers/get_addresses.php'; $responseArray['response'] = get_addresses($values); $responseArray['message'] = 'Addresses got'; break; case 'update_address': include_once __DIR__ . '/customers/update_address.php'; $responseArray['response'] = update_address($values); $responseArray['message'] = 'Address updated'; break; case 'add_user': include_once __DIR__ . '/customers/add_user.php'; $responseArray['response'] = add_user($values); $responseArray['message'] = 'User successfully added'; break; case 'get_users': include_once __DIR__ . '/customers/get_users.php'; $responseArray['response'] = get_users($values);
case "--help": display_help(); return 0; case "--list-host-templates": display_host_templates(get_host_templates()); return 0; default: print "ERROR: Invalid Parameter " . $parameter . "\n\n"; display_help(); return 1; } } /* process the various lists into validation arrays */ $host_templates = get_host_templates(); $hosts = get_hosts_by_description(); $addresses = get_addresses(); /* process templates */ if (!isset($host_templates[$template_id])) { echo "Unknown template id ({$template_id})\n"; return 1; } /* process host description */ if (isset($hosts[$description])) { db_execute("update host set hostname='{$ip}' where id=" . $hosts[$description]); echo "This host already exists in the database ({$description}) device-id: (" . $hosts[$description] . ")\n"; return 1; } if ($description == "") { echo "You must supply a description for all hosts!\n"; return 1; }