function form(&$err) { if (isset($_POST)) { global $_POST; } else { return; } global $db; if (sending()) { $_SESSION = array(); if (isset($_POST['flash'])) { $flash = ' -flash'; } else { $flash = ''; } if ($list = getlist($_POST['number'])) { foreach ($list->numbers as $no) { $err->out = Gammu::infiniteSend($_POST['message'], $no, $flash); if ($err->out != 0) { $err->numberInError[] = getNameOf($no); } } } else { $users = $db->table('directory')->find(); foreach ($users as $user) { if (isset($user->name) and $user->name == $_POST['number']) { $_POST['number'] = $user->number; } } $_POST['number'] = str_replace(' ', '', $_POST['number']); $err->out = Gammu::send($_POST['message'], $_POST['number'], $flash); if ($err->out != 0) { formSetSessionValues(); } } } else { if (saveContact()) { $_POST['number'] = str_replace(' ', '', $_POST['number']); $err->in = $db->table('directory')->insert($_POST); } else { if (saveList()) { $list = array("list" => $_POST['list']); $i = 1; while (isset($_POST['number' . $i])) { if (!empty($_POST['number' . $i])) { if ($number = getNumberOfName($_POST['number' . $i])) { $list['numbers'][] = $number; } else { $list['numbers'][] = $_POST['number' . $i]; } } $i++; } $err->listin = $db->table('lists')->insert($list); } else { $err->errorMessages(); } } } }
function _moduleContent(&$smarty, $module_name) { //global variables global $arrConf; //folder path for custom templates $local_templates_dir = getWebDirModule($module_name); //conexion resource $pDB = new paloDB($arrConf['elastix_dsn']['elastix']); //return array("idUser"=>$idUser,"id_organization"=>$idOrganization,"userlevel"=>$userLevel1,"domain"=>$domain); global $arrCredentials; //actions $accion = getAction(); switch ($accion) { case 'saveNew': $content = saveContact($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); break; case "saveEdit": $content = editContact($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); break; case 'uploadImageContact': $content = uploadImageContact($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); break; case 'deleteContacts': $content = deleteContacts($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); break; case 'uploadCSV': $content = uploadCSV($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); break; case 'templateContact': $content = templateContact($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); break; case "getImageExtContact": $content = getImageExtContact($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); break; case "getImageTmp": $content = getImageTmp($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); break; case "call2phone": $content = call2phone($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); break; case "transfer_call": $content = transferCALL($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); break; default: $content = reportContact($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); break; } return $content; }
$task = JRequest::getCmd('task'); $id = JRequest::getVar('id', 0, 'get', 'int'); $cid = JRequest::getVar('cid', array(0), 'post', 'array'); JArrayHelper::toInteger($cid, array(0)); switch ($task) { case 'add': editContact(false); break; case 'edit': editContact(true); break; case 'apply': case 'save': case 'save2new': case 'save2copy': saveContact($task); break; case 'remove': removeContacts($cid); break; case 'publish': changeContact($cid, 1); break; case 'unpublish': changeContact($cid, 0); break; case 'orderup': orderContacts($cid[0], -1); break; case 'orderdown': orderContacts($cid[0], 1);
// Store the contacts in an array of objects $contacts = array(); while ($record = mysql_fetch_object($result)) { array_push($contacts, $record); } // Return the contacts return $contacts; } // Let's handle the AJAX calls now $action = $_POST['action']; if ($action == "add") { // Get the post variables for the new contact $name = $_POST['name']; $phone = $_POST['phone']; // Save the new contact saveContact($name, $phone); $output['msg'] = $name . " has been saved."; // Reload the contacts $output['contacts'] = getContacts(); echo json_encode($output); } else { if ($action == "delete") { // Collect the ID we wish to delete $id = $_POST['id']; //delete contact with that ID deleteContact($id); $output['msg'] = "Contact deleted."; // Reload the contacts $output['contacts'] = getContacts(); echo json_encode($output); } else {
$cid = mosGetParam($_POST, 'cid', array(0)); if (!is_array($cid)) { $cid = array(0); } switch ($task) { case 'new': editContact('0', $option); break; case 'edit': editContact($cid[0], $option); break; case 'editA': editContact($id, $option); break; case 'save': saveContact($option); break; case 'remove': removeContacts($cid, $option); break; case 'publish': changeContact($cid, 1, $option); break; case 'unpublish': changeContact($cid, 0, $option); break; case 'orderup': orderContacts($cid[0], -1, $option); break; case 'orderdown': orderContacts($cid[0], 1, $option);
// Author: Keran McKenzie // Date: 20 Jan 2013 // // Provided as sample only, not intended for production // This page uses the $type variable to change its setup // *******************************************/ // first up, what type of contacts list are we getting? $type = ''; //$_GET['type']; require_once 'header.php'; // do we have form content to submit if (isset($_POST['inputCoLastName'])) { // save the contact // type, ID, lastname, firstname, isactive, taxcodeid, freighttaxcodeid $save = saveContact($_POST['type'], '', $_POST['inputCoLastName'], $_POST['inputFirstName'], 'True', 'GST', 'GST'); ?> <div class="alert alert-success"> <p><strong>Saved</strong> contact to AccountRight</p> <p><a class="btn btn-primary btn-large" href="<?php echo $pageURL . $_POST['type']; ?> s/">Return to the <?php echo $_POST['type']; ?> list</a> </div> <?php } else { ?> <!-- setup a 2 col responsive page -->
$new .= '}'; return $new; } function saveContact() { $datafile = fopen("data/data.json", "a+"); if (!$datafile) { echo "<script>alert('Data not existed!')</script>"; } else { $contact_list = $contact_list . addNewContact(); file_put_contents("data/data.json", $contact_list); } fclose($datafile); } // Call the function saveContact() saveContact(); echo "Thank you for joining us"; } else { ?> <form> <fieldset> <legend>Add New Contact</legend> <input type="text" name="fullname" placeholder="First name and last name" required /> <br /> <input type="email" name="email" placeholder="*****@*****.**" required /> <br /> <input type="text" name="phone" placeholder="Personal phone number: mobile, home phone etc." required /> <br /> <input type="submit" name="submit" class="button" value="Add Contact"/> <input type="button" name="cancel" class="button" value="Reset" /> </fieldset> </form> <?php
public function curd() { if (IS_POST) { $data['customer_name'] = str_rp(trim($_POST['customer_name'])); $data['company_name'] = str_rp(trim($_POST['company_name'])); $data['zip_code'] = intval(trim($_POST['zip_code'])); $data['province_id'] = intval($_POST['province_id']); $data['city_id'] = intval($_POST['city_id']); $data['district_id'] = intval($_POST['area']); $data['address'] = str_rp(trim($_POST['address'])); $data['mobile'] = str_rp(trim($_POST['mobile'])); $data['email'] = str_rp(trim($_POST['email'])); $data['create_time'] = NOW_TIME; $data['status'] = intval($_POST['status']); $data['remark'] = str_rp(trim($_POST['remark'])); $data['sort'] = intval($_POST['sort']); $customer_id = intval($_POST['customer_id']); if ($data['email']) { saveContact($data['email'], 'email', '客户管理'); } if ($data['mobile']) { saveContact($data['mobile'], 'mobile', '客户管理'); } if ($customer_id) { $issuper = M('Admin')->where(array('admin_id' => AID))->getField('admin_issuper'); if (!$issuper) { $map['creat_admin_id'] = array('in', '0,' . AID); } $map['customer_id'] = $customer_id; $res = $this->model->where($map)->save($data); if ($res) { $this->success('修改客户资料成功', U('index')); } else { $this->error('修改客户资料失败'); } } else { $data['creat_admin_id'] = AID; $res = $this->model->add($data); if ($res) { $this->success('添加客户资料成功', U('index')); } else { $this->error('添加客户资料失败'); } } } elseif (IS_GET) { $issuper = M('Admin')->where(array('admin_id' => AID))->getField('admin_issuper'); if (!$issuper) { $where['creat_admin_id'] = array('in', '0,' . AID); } $where['customer_id'] = intval($_GET['id']); $info = $this->model->where($where)->find(); $this->title = '客户信息'; $this->assign('info', $info); $dwhere['upid'] = 0; $dwhere['status'] = 1; $this->province = M('District')->where($dwhere)->order('d_sort')->select(); if ($info['province_id']) { $dwhere['upid'] = $info['province_id']; $dwhere['status'] = 1; $this->city = M('District')->where($dwhere)->order('d_sort')->select(); } if ($info['city_id']) { $dwhere['upid'] = $info['city_id']; $dwhere['status'] = 1; $this->district = M('District')->where($dwhere)->order('d_sort')->select(); } $this->display(); } }
public function editOrder() { if (IS_POST) { $order_id = intval($_POST['order_id']); $issuper = M('Admin')->where(array('admin_id' => AID))->getField('admin_issuper'); if (!$issuper) { $order_where['creat_admin_id'] = array('in', '0,' . AID); } $order_where['order_id'] = $order_id; $order = $this->model->where($order_where)->find(); if (empty($order)) { $this->error('非法操作'); } $data['order_sn'] = order_sn(); $data['out_sn'] = str_rp($_POST['out_sn'], 1); $data['buyer_name'] = str_rp($_POST['true_name'], 1); $data['payment_time'] = strtotime($_POST['payment_time']); $data['add_time'] = strtotime($_POST['add_time']); $data['discount'] = floatval($_POST['discount']); $data['order_amount'] = floatval($_POST['order_amount']); $data['email'] = str_rp($_POST['email'], 1); if ($data['email']) { saveContact($data['email'], 'email', '订单'); $member_id = M('Member')->where(array('email' => $data['email']))->getField('member_id'); } $data['mobile'] = str_rp($_POST['mob_phone'], 1); if ($data['mobile']) { saveContact($data['mobile'], 'mobile', '订单'); $member_id = M('Member')->where(array('mobile' => $data['mobile']))->getField('member_id'); } if ($member_id) { $data['member_id'] = $member_id; } else { $data['member_id'] = 0; } $data['source'] = str_rp($_POST['source'], 1); $data['creat_admin_id'] = AID; $data['customer_id'] = intval($_POST['customer_id']); $res = $this->model->where($order_where)->save($data); $data['OrderAddress']['company_name'] = str_rp($_POST['company_name'], 1); $data['OrderAddress']['true_name'] = $data['buyer_name']; $data['OrderAddress']['buyer_id'] = $data['member_id']; $data['OrderAddress']['prov_id'] = intval($_POST['province_id']); $data['OrderAddress']['city_id'] = intval($_POST['city_id']); $data['OrderAddress']['area_id'] = intval($_POST['area_id']); $data['OrderAddress']['address'] = str_rp($_POST['address'], 1); $data['OrderAddress']['zip_code'] = intval($_POST['zip_code']); $data['OrderAddress']['mob_phone'] = $data['mobile']; $data['OrderAddress']['email'] = $data['email']; $data['OrderAddress']['add_time'] = $data['add_time']; M('OrderAddress')->where(array('order_id' => $order_id))->save($data['OrderAddress']); $data['OrderLog'][0]['order_state'] = '订单完成'; $data['OrderLog'][0]['log_time'] = $data['add_time']; $data['OrderLog'][0]['state_info'] = '管理员录入订单'; $data['OrderLog'][0]['operator'] = '管理员-' . get_admin_nickname(AID); M('OrderLog')->where(array('order_id' => $order_id))->add($data['OrderLog'][0]); foreach ($_POST['goods'] as $key => $val) { $goods = M('Goods')->where(array('goods_id' => $val['goods_id']))->find(); if (!empty($goods)) { $data['OrderGoods'][$key]['order_id'] = $order_id; $data['OrderGoods'][$key]['goods_id'] = $goods['goods_id']; $data['OrderGoods'][$key]['goods_price'] = $val['goods_price']; $data['OrderGoods'][$key]['goods_mkprice'] = $val['goods_mktprice']; $data['OrderGoods'][$key]['goods_num'] = $val['goods_num']; $data['OrderGoods'][$key]['goods_name'] = $goods['goods_name']; $data['OrderGoods'][$key]['goods_image'] = $goods['goods_pic']; } } M('OrderGoods')->where(array('order_id' => $order_id))->delete(); M('OrderGoods')->addAll($data['OrderGoods']); if (empty(intval($_POST['customer_id']))) { $customer['company_name'] = str_rp($_POST['company_name'], 1); $customer['customer_name'] = $data['buyer_name']; $customer['province_id'] = intval($_POST['province_id']); $customer['city_id'] = intval($_POST['city_id']); $customer['district_id'] = intval($_POST['area_id']); $customer['address'] = str_rp($_POST['address'], 1); $customer['zip_code'] = intval($_POST['zip_code']); $customer['mobile'] = $data['mobile']; $customer['email'] = $data['email']; $customer['creat_admin_id'] = AID; $customer['create_time'] = NOW_TIME; $customer['status'] = 1; $customer['remark'] = '来自订单录入'; $customer['sort'] = 0; if (!empty($customer['company_name']) || !empty($customer['customer_name'])) { M('Customer')->add($customer); } } if ($res) { $this->success('录入订单成功', U('order')); } else { $this->error('录入订单失败'); } } elseif (IS_GET) { $order_id = intval($_GET['order_id']); $order_where['order_id'] = $order_id; $issuper = M('Admin')->where(array('admin_id' => AID))->getField('admin_issuper'); if (!$issuper) { $order_where['creat_admin_id'] = array('in', '0,' . AID); } $order = $this->model->relation(true)->where($order_where)->find(); if (empty($order)) { $this->error('非法操作'); } else { $this->order = $order; } $province = M('District')->where(array('level' => 1, 'status' => 1))->order('d_sort')->select(); $city = M('District')->where(array('level' => 2, 'status' => 1, 'upid' => $order['prov_id']))->order('d_sort')->select(); $area = M('District')->where(array('level' => 3, 'status' => 1, 'upid' => $order['city_id']))->order('d_sort')->select(); $this->assign('province', $province); $this->assign('city', $city); $this->assign('area', $area); $this->display('addOrder'); } }
<?php if (is_dir($contacts[0]['contact_logo_path']) && ($pp = opendir($contacts[0]['contact_logo_path']))) { while (($file = readdir($pp)) !== false) { if ($file != "." && $file != "..") { $img[] = $file; } } closedir($pp); } if (isset($detail) && $detail == 'done') { $_POST['file'] = $_FILES; if (!empty($_POST['contact_name']) && !empty($_POST['contact_street']) && !empty($_POST['contact_zip']) && !empty($_POST['contact_city'])) { $msg = saveContact($_POST, $db); } if (isset($msg)) { $_SESSION['has_contact'] = true; header('Location: /dashboard/contacts'); } else { $message = '<p class="error">Ihr Kontakt konnte nicht angelegt werden.<p>'; } } if (isset($detail) && $detail == 'edit') { $up = updateContact($_POST, $db); if ($up === true) { $_SESSION['has_contact'] = true; header('Location: /dashboard/contacts'); } } if (isset($detail) && $detail == 'delete') { $del = deleteContactLogo($_POST['logo_path']);
/** * 注册 */ public function register() { if (IS_POST) { $data = array(); $smscode = strtolower(trim($_POST['smscode'])); if (empty($smscode)) { $this->error('验证码为空'); } if ($_POST['s_class'] == 'mobile') { $data['mobile'] = str_rp(trim($_POST['mobile'])); if ($smscode == session('smscode') && session('codetype') == 'register' && session('mobile') == $data['mobile'] && !empty($data['mobile'])) { $data['pwd'] = re_md5($_POST['pwd']); $data['register_time'] = NOW_TIME; $data['member_status'] = 1; $api = 'http://int.dpool.sina.com.cn/iplookup/iplookup.php'; $ipparam['format'] = 'js'; $ipparam['ip'] = get_client_ip(); $res = get_api($api, $ipparam, 'array'); if (!empty($res['city'])) { $data['city'] = $res['city']; } $member_id = $this->model->add($data); if ($member_id) { M('Order')->where(array('mobile' => $data['mobile']))->setField('member_id', $member_id); saveContact($data['mobile'], 'mobile', '注册'); unset($data); session(null); session('member_id', $member_id); $this->success("注册成功!", U('Member/index')); exit; } } else { $this->error('验证码错误'); } } elseif ($_POST['s_class'] == 'email') { $data['email'] = filter_var($_POST['email'], FILTER_VALIDATE_EMAIL); if ($smscode == session('smscode') && session('codetype') == 'register' && session('email') == $data['email'] && !empty($data['email'])) { $data['pwd'] = re_md5($_POST['pwd']); $data['register_time'] = NOW_TIME; $data['member_status'] = 1; $api = 'http://int.dpool.sina.com.cn/iplookup/iplookup.php'; $ipparam['format'] = 'js'; $ipparam['ip'] = get_client_ip(); $res = get_api($api, $ipparam, 'array'); if (!empty($res['city'])) { $data['city'] = $res['city']; } $member_id = $this->model->add($data); if ($member_id) { M('Order')->where(array('email' => $data['email']))->setField('member_id', $member_id); saveContact($data['email'], 'email', '注册'); unset($data); session(null); session('member_id', $member_id); $this->success("注册成功!", U('Member/index')); exit; } } else { $this->error('验证码错误'); } } } elseif (IS_GET) { $this->check_login(); $this->display(); } }
function updateHold($smarty, $msi, $user_id, $contact_id) { $ButtonAction = $_POST['buttonAction']; $transtype = substr($ButtonAction, 0, 3); $err_msg = ''; if ($transtype == 'Add') { switch ($ButtonAction) { case "AddAddress": insertPostAddress($msi, 'A', 'add', $user_id, $contact_id, $err_msg); break; case "AddPhone": insertPostPhone($msi, 'A', 'add', $user_id, $contact_id, $err_msg); break; case "AddEmail": insertPostEmail($msi, 'A', 'add', $user_id, $contact_id, $err_msg); break; } } elseif ($transtype == 'Del') { /* If there is an A=add rec in the hold table, delete it. A=add recs have the data_id changed to negative. If not, add a D=delete rec */ // First, get id of item to delete $uloc = strrpos($ButtonAction, "_"); $data_id = substr($ButtonAction, $uloc + 1); $ButtonAction = substr($ButtonAction, 0, $uloc); if ($data_id < 0) { /* there is a hold_ table A=add rec for this address/phone/email */ switch ($ButtonAction) { case "DeleteAddress": $stmt = $msi->prepare("delete from hold_address " . "where action='A' and hold_id=?"); break; case "DeletePhone": $stmt = $msi->prepare("delete from hold_phone " . "where action='A' and hold_id=?"); break; case "DeleteEmail": $stmt = $msi->prepare("delete from hold_email " . "where action='A' and hold_id=?"); break; } $hold_id = -$data_id; $stmt->bind_param('i', $hold_id); } else { /* This is to delete a rec that was already in the live database */ switch ($ButtonAction) { case "DeleteAddress": $stmt = $msi->prepare("insert into hold_address " . "(action,contact_id,address_id) " . "values ('D',?,?)"); break; case "DeletePhone": $stmt = $msi->prepare("insert into hold_phone " . "(action,contact_id,phone_id) values ('D',?,?)"); break; case "DeleteEmail": $stmt = $msi->prepare("insert into hold_email " . "(action,contact_id,email_id) values ('D',?,?)"); break; } $stmt->bind_param('ii', $contact_id, $data_id); } $stmt->execute(); $stmt->close(); } else { if ($transtype == 'UnD') { /* undelete - delete D rec from hold table */ // First, get id of item to delete -> $data_id $uloc = strrpos($ButtonAction, "_"); $data_id = substr($ButtonAction, $uloc + 1); $ButtonAction = substr($ButtonAction, 0, $uloc); switch ($ButtonAction) { case "UnDeleteAddress": $stmt = $msi->prepare("delete from hold_address " . "where action='D' and address_id=?"); break; case "UnDeletePhone": $stmt = $msi->prepare("delete from hold_phone " . "where action='D' and phone_id=?"); break; case "UnDeleteEmail": $stmt = $msi->prepare("delete from hold_email " . "where action='D' and email_id=?"); break; } $stmt->bind_param('i', $data_id); $stmt->execute(); $stmt->close(); } else { if ($transtype == 'Sav') { // first, UserData /* Delete hold_contact record for this contact_id if there is one. If there are changes in the $_POST data, a new one will be created */ $stmt = $msi->prepare("delete from hold_contact " . "where contact_id=?"); $stmt->bind_param("i", $contact_id); $stmt->execute(); $stmt->close(); $user_data = new UserData($msi, $smarty, $user_id, $contact_id); if (isChange($user_data->ud, 0, "o")) { $stmt = $msi->prepare("insert into hold_contact " . "(contact_id,user_id,title_id,primary_name," . "first_name,middle_name,degree_id,nickname," . "birth_date,gender,username) values " . "(?,?,?,?,?,?,?,?,str_to_date(?,'%m/%d/%Y'),?,?)"); $stmt->bind_param("iiisssissss", $contact_id, $user_id, $_POST["title_id"], $_POST["primary_name"], $_POST["first_name"], $_POST["middle_name"], $_POST["degree_id"], $_POST["nickname"], $_POST["birth_date"], $_POST["gender"], $_SESSION['username']); $stmt->execute(); $stmt->close(); } unset($user_data); $contact_data = new ContactData($msi, $smarty, $user_id, $contact_id); saveContact($msi, $smarty, 'address', $contact_data->ad, $user_id, $contact_id, insertPostAddress); saveContact($msi, $smarty, 'phone', $contact_data->ph, $user_id, $contact_id, insertPostPhone); saveContact($msi, $smarty, 'email', $contact_data->em, $user_id, $contact_id, insertPostEmail); unset($contact_data); } } } displayFooter($smarty, $err_msg); }
<?php /***************************************** // // Show the contact details page template for my.Contacts // Author: Keran McKenzie // Date: 19 Jan 2013 // // Provided as sample only, not intended for production // This page uses the $type variable to change its setup // *******************************************/ // // with this page we want to pull the contact details before we build the page // as we are going to use Google Maps & we load the maps javascript in the header of the page // we need pull and process the data before loading the header // // lets just fudge it $test = saveContact($type, $id, 'KeranTest', 'TestKeran', 'False', 'GST', 'GST'); print_r($test);