/** * Given a list of code names, return the list of topic ids */ public static function idsFromNames(array $names) { $ids = []; foreach ($names as $name) { $topic = static::whereName($name)->first(); if (!$topic) { $topic = new Code(); $topic->name = $name; $topic->save(); } $ids[] = $topic->id; } return $ids; }
public static function makeCode($data) { $code = rand(10000000, 99999999); if (self::checkCode($code)) { $a[] = $code; $proxy = new Code(); $proxy->code = $code; $proxy->userId = $data['userId']; $proxy->type = $data['type']; $proxy->startDate = $data['startDate']; $proxy->endDate = $data['endDate']; $proxy->createTime = date('Y-m-d H:i:s'); $proxy->times = $data['times']; $proxy->ordercompanyproductId = $data['ordercompanyProductId']; $proxy->save(); } else { return false; } return $a; }
$titleError = "Code Title is required!"; $error = true; } if ($session->is_logged_in()) { $code->user_id = $session->user_id; $code->privacy = $_POST['privacy']; } if (!empty($_POST['code'])) { $code->code = $_POST['code']; } else { $codeError = "Code field is required!"; $error = true; } $code->lang = $_POST['lang']; if (!$error) { if ($code->save()) { $_SESSION['message'] = 'Horrah! Your code is saved and ready to share!'; header('Location: code.php?id=' . $code->id); exit; } else { $database->check_error(); } } } ?> <div class="container"> <?php if ($session->has_message()) { ?>
if (!auth::mobile($phone)) { $return_data['return_data'] = '手机格式输入不正确'; exit(json_encode($return_data)); } //判断发送类型 $type = isset($_REQUEST['type']) ? intval($_REQUEST['type']) : 0; if ($type == 1) { //找回密码 // echo $phone;exit; if (!$Db->Fetch($Db->ThisQuery("SELECT 1 FROM `" . $db_prefix . "member` WHERE account={$phone}"))) { exit(json_encode(array('state' => "0", 'return_data' => '该手机用户不存在'))); } //找回密码 $randCode = substr(mt_rand(), 0, 6); $content = '验证码:' . $randCode . '(此验证码用于会员找回密码使用,若非本人操作,请不予理会,此信息免费)【华夏君拓】'; $sms->save($phone, $randCode, 1); exit(json_encode(array('state' => "1", 'return_data' => '发送成功' . $content))); if ($sms->send_code($phone, $content)) { $sms->save($phone, $randCode, 1); exit(json_encode(array('state' => "1", 'return_data' => '发送成功'))); } else { exit(json_encode(array('state' => "0", 'return_data' => '发送失败'))); } } else { //注册验证码 if ($Db->Fetch($Db->ThisQuery("SELECT 1 FROM `" . $db_prefix . "member` WHERE account={$phone}"))) { exit(json_encode(array('state' => "0", 'return_data' => '该手机已被注册,请使用其他手机'))); } $randCode = substr(mt_rand(), 0, 6); $content = '验证码:' . $randCode . '(此验证码用于用户注册会员使用,若非本人操作,请不予理会,此信息免费)【华夏君拓】'; $sms->save($phone, $randCode, 0);