当前位置: 首页>>代码示例>>PHP>>正文


PHP generate_code函数代码示例

本文整理汇总了PHP中generate_code函数的典型用法代码示例。如果您正苦于以下问题:PHP generate_code函数的具体用法?PHP generate_code怎么用?PHP generate_code使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了generate_code函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: form

 public function form()
 {
     \CI::form_validation()->set_rules('to_email', 'lang:recipient_email', 'trim|required');
     \CI::form_validation()->set_rules('to_name', 'lang:recipient_name', 'trim|required');
     \CI::form_validation()->set_rules('from', 'lang:sender_name', 'trim|required');
     \CI::form_validation()->set_rules('personal_message', 'lang:personal_message', 'trim');
     \CI::form_validation()->set_rules('beginning_amount', 'lang:amount', 'trim|required|numeric');
     $data['page_title'] = lang('add_gift_card');
     if (\CI::form_validation()->run() == FALSE) {
         $this->view('gift_card_form', $data);
     } else {
         $save['code'] = generate_code();
         // from the string helper
         $save['to_email'] = \CI::input()->post('to_email');
         $save['to_name'] = \CI::input()->post('to_name');
         $save['from'] = \CI::input()->post('from');
         $save['personal_message'] = \CI::input()->post('personal_message');
         $save['beginning_amount'] = \CI::input()->post('beginning_amount');
         \CI::GiftCards()->saveCard($save);
         if (\CI::input()->post('sendNotification')) {
             \GoCart\Emails::giftCardNotification($save);
         }
         \CI::session()->set_flashdata('message', lang('message_saved_gift_card'));
         redirect('admin/gift-cards');
     }
 }
开发者ID:lekhangyahoo,项目名称:gonline,代码行数:26,代码来源:AdminGiftCards.php

示例2: user_login

function user_login($mysqli, $login, $password)
{
    // Получим данные пользователя
    $user_data = user_get_data_by_login($mysqli, $login);
    // Сравниваем пароли
    if ($user_data['password'] === md5(md5($password))) {
        // Пароли сошлись
        // Генерируем случайное число и шифруем его
        $hash = md5(generate_code(10));
        // Запрос
        $query = "UPDATE users SET hash='{$hash}' WHERE id='{$user_data['id']}'";
        // Записываем в БД новый хеш авторизации и ID
        if ($result = $mysqli->query($query)) {
            // Запись прошла успешно
            // Запишем событие в журнал
            event_add($mysqli, 15, "Пользователь принял смену.", $_POST['login']);
            // Запишем в куки id
            setcookie("id", $user_data['id'], time() + 60 * 60 * 24 * 30);
            // и хэш
            setcookie("hash", $hash, time() + 60 * 60 * 24 * 30);
            // Переадресовываем на главную
            header("Location: index.php");
            exit;
            // Сообщим об успешном входе
            return "Добро пожаловать";
        }
        return "Ошибка записи в БД";
    } else {
        return "Неправильная комбинация имени пользователя и пароля";
    }
}
开发者ID:Other-Proto,项目名称:Neptune,代码行数:31,代码来源:login.php

示例3: entry_captcha

 function entry_captcha()
 {
     //session_start();
     //生成验证码图片
     Header("Content-type: image/PNG");
     $im = imagecreate(44, 18);
     // 画一张指定宽高的图片
     $back = ImageColorAllocate($im, 245, 245, 245);
     // 定义背景颜色
     imagefill($im, 0, 0, $back);
     //把背景颜色填充到刚刚画出来的图片中
     $vcodes = "";
     //srand((double)microtime()*1000000);
     //生成4位数字
     $vcodes = generate_code(4);
     for ($i = 0; $i < 4; $i++) {
         $font = ImageColorAllocate($im, rand(100, 255), rand(0, 100), rand(100, 255));
         // 生成随机颜色
         $authnum = $vcodes[$i];
         imagestring($im, 5, 2 + $i * 10, 1, $authnum, $font);
     }
     $_SESSION['captcha'] = strtolower($vcodes);
     for ($i = 0; $i < 100; $i++) {
         $randcolor = ImageColorallocate($im, rand(0, 255), rand(0, 255), rand(0, 255));
         imagesetpixel($im, rand() % 70, rand() % 30, $randcolor);
         // 画像素点函数
     }
     ImagePNG($im);
     ImageDestroy($im);
 }
开发者ID:questionlin,项目名称:readcat,代码行数:30,代码来源:Vindex.php

示例4: deal_code_form

 function deal_code_form($id = false)
 {
     $this->load->helper('form');
     $this->load->library('form_validation');
     $data['page_title'] = 'Add Deal Code';
     //default values are empty if the deal_type is new
     $data['id'] = '';
     $data['code_no'] = '';
     if ($id) {
     }
     $this->form_validation->set_rules('code_no', 'Number of codes', 'trim|required|is_numeric');
     if ($this->form_validation->run() == FALSE) {
         $this->load->view($this->config->item('admin_folder') . '/deal_code_form', $data);
     } else {
         $code_nums = $this->input->post('code_no');
         $k = $code_nums;
         $this->load->helper('string');
         while ($k) {
             $code = generate_code(6);
             if (!$this->Dealsign_model->check_deal_code($code)) {
                 $data = array('id' => '', 'deal_code' => $code, 'is_used' => 0);
                 $this->Dealsign_model->save_deal_code($data);
                 $k--;
             }
         }
         $this->session->set_flashdata('message', '<b>' . $code_nums . '</b> codes has been generated successfully');
         //go back to the deal_city list
         redirect($this->config->item('admin_folder') . '/dealsign/deal_codes');
     }
 }
开发者ID:dealsign,项目名称:public_html,代码行数:30,代码来源:dealsign.php

示例5: process_form

function process_form()
{
    // INITIAL DATA FETCHING
    global $school_name, $email;
    // so that the show_form function can use these values later
    $school_name = htmlentities(trim($_POST['school_name']));
    $email = htmlentities($_POST['email']);
    $name_msg = validate_school_name($school_name);
    $recaptcha_msg = validate_recaptcha();
    $email_msg = validate_coach_email($email);
    if ($name_msg !== true) {
        alert($name_msg, -1);
    } else {
        if ($recaptcha_msg !== true) {
            alert($recaptcha_msg, -1);
        } else {
            if ($email_msg !== true) {
                alert($email_msg, -1);
            } else {
                // ** All information has been validated at this point **
                $access_code = generate_code(5);
                // Create database entry
                DB::insert('schools', array('name' => $school_name, 'coach_email' => $email, 'access_code' => $access_code));
                // Get user id (MySQL AUTO_INCREMENT id)
                $id = DB::insertId();
                global $LMT_EMAIL;
                $lmt_year = htmlentities(map_value('year'));
                $lmt_date = htmlentities(map_value('date'));
                // Send the email
                $url = get_site_url() . '/LMT/Registration/Signin?ID=' . $id . '&Code=' . $access_code;
                $subject = "LMT {$lmt_year} Account";
                $body = <<<HEREDOC
To: {$school_name}

Thank you for registering your school for the LMT! The contest will be 
held on [b]{$lmt_date} [/b] at Lexington High School.

You may register teams for LMT {$lmt_year} via the link below. This link will
also enable you to modify teams as long as registration is open.

[b][url]{$url} [/url][/b]

If you have any questions, please contact us at [email]{$LMT_EMAIL} [/email].
HEREDOC;
                lmt_send_email(array($email => $school_name), $subject, $body);
                // Show the post-registration message
                echo <<<HEREDOC
      <h1>Coach Registration</h1>
      
      <div class="text-centered">
        Your account was created. Please check your email inbox for a confirmation email.
      </div>
HEREDOC;
                die;
            }
        }
    }
}
开发者ID:lhsmath,项目名称:lhsmath.org,代码行数:58,代码来源:Coach.php

示例6: forms

 function forms()
 {
     $data = $this->earndb->get_last_faktur();
     print_r($data);
     //generate kode faktur baru --> generate_code_helper
     $faktur = generate_code($data);
     print_r($faktur);
     $this->load->view('earn_form_inside', array('faktur' => $faktur));
 }
开发者ID:roniwahyu,项目名称:Sistem-Informasi-Peternakan,代码行数:9,代码来源:earn.php

示例7: lostPassword

function lostPassword($username, $email)
{
    $randomPassword = generate_code(10);
    if (changePassword($username, $randomPassword, $randomPassword)) {
        if (sendLostPasswordEmail($username, $email, $randomPassword)) {
            return true;
        }
    }
    return false;
}
开发者ID:audunel,项目名称:anthropos,代码行数:10,代码来源:user.functions.inc.php

示例8: GetID

function GetID($prefix)
{
    //第一步:初始化种子
    //microtime(); 是个数组
    /*$seedstr =split(" ",microtime(),5);
    		$seed =$seedstr[0]*10000;
    		//第二步:使用种子初始化随机数发生器
    		srand($seed);
    	*/
    //第三步:生成指定范围内的随机数
    $random = rand(1000, 10000);
    $random .= generate_code();
    $filename = date("Ymd", time()) . $random . $prefix;
    return $filename;
}
开发者ID:snamper,项目名称:CI_xiaoshuhaochi,代码行数:15,代码来源:uploads.php

示例9: chec_code

function chec_code($code)
{
    $code = trim($code);
    //удаляем пробелы
    $array_mix = preg_split('//', generate_code(), -1, PREG_SPLIT_NO_EMPTY);
    $m_code = preg_split('//', $code, -1, PREG_SPLIT_NO_EMPTY);
    $result = array_intersect($array_mix, $m_code);
    if (strlen(generate_code()) != strlen($code)) {
        return FALSE;
    }
    if (sizeof($result) == sizeof($array_mix)) {
        return TRUE;
    } else {
        return FALSE;
    }
}
开发者ID:VovaGurovskiy,项目名称:EnergoRemote,代码行数:16,代码来源:save_user.php

示例10: form

 function form()
 {
     $this->form_validation->set_rules('to_email', 'lang:recipient_email', 'trim|required');
     $this->form_validation->set_rules('to_name', 'lang:recipient_name', 'trim|required');
     $this->form_validation->set_rules('from', 'lang:sender_name', 'trim|required');
     $this->form_validation->set_rules('personal_message', 'lang:personal_message', 'trim');
     $this->form_validation->set_rules('beginning_amount', 'lang:amount', 'trim|required|numeric');
     $data['page_title'] = lang('add_giftcard');
     if ($this->form_validation->run() == FALSE) {
         $this->load->view($this->config->item('admin_folder') . '/giftcard_form', $data);
     } else {
         $this->load->helper('utility_helper');
         $save['code'] = generate_code();
         // from the utility helper
         $save['to_email'] = $this->input->post('to_email');
         $save['to_name'] = $this->input->post('to_name');
         $save['from'] = $this->input->post('from');
         $save['personal_message'] = $this->input->post('personal_message');
         $save['beginning_amount'] = $this->input->post('beginning_amount');
         $save['activated'] = 1;
         $this->Gift_card_model->save_card($save);
         if ($this->input->post('send_notification')) {
             //get the canned message for gift cards
             $row = $this->db->where('id', '1')->get('canned_messages')->row_array();
             // set replacement values for subject & body
             $row['subject'] = str_replace('{from}', $save['from'], $row['subject']);
             $row['subject'] = str_replace('{site_name}', $this->config->item('company_name'), $row['subject']);
             $row['content'] = str_replace('{code}', $save['code'], $row['content']);
             $row['content'] = str_replace('{amount}', $save['beginning_amount'], $row['content']);
             $row['content'] = str_replace('{from}', $save['from'], $row['content']);
             $row['content'] = str_replace('{personal_message}', nl2br($save['personal_message']), $row['content']);
             $row['content'] = str_replace('{url}', $this->config->item('base_url'), $row['content']);
             $row['content'] = str_replace('{site_name}', $this->config->item('company_name'), $row['content']);
             $this->load->library('email');
             $config['mailtype'] = 'html';
             $this->email->initialize($config);
             $this->email->from($this->config->item('email'));
             $this->email->to($save['to_email']);
             $this->email->subject($row['subject']);
             $this->email->message($row['content']);
             $this->email->send();
         }
         $this->session->set_flashdata('message', lang('message_saved_giftcard'));
         redirect($this->config->item('admin_folder') . '/giftcards');
     }
 }
开发者ID:jonyhandoko,项目名称:khayana,代码行数:46,代码来源:giftcards.php

示例11: img_code

function img_code()
{
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    header("Last-Modified: " . gmdate("D, d M Y H:i:s", 10000) . " GMT");
    header("Cache-Control: no-store, no-cache, must-revalidate");
    header("Cache-Control: post-check=0, pre-check=0", false);
    header("Pragma: no-cache");
    header("Content-Type:image/png");
    //защита от кэшировани¤...кстати сказать не очень надежна¤...
    $linenum = 2;
    //линии
    $img_arr = array("codegen.png", "codegen0.png");
    $font_arr = array();
    $font_arr[0]["fname"] = "verdana.ttf";
    //ttf шрифты, можно заменить на свои
    $font_arr[0]["size"] = 16;
    //размер
    $font_arr[1]["fname"] = "times.ttf";
    //ttf шрифты, можно заменить на свои
    $font_arr[1]["size"] = 16;
    //размер
    $n = rand(0, sizeof($font_arr) - 1);
    $img_fn = $img_arr[rand(0, sizeof($img_arr) - 1)];
    $im = imagecreatefrompng(code_dir . $img_fn);
    //создаем изображение со случайным фоном
    for ($i = 0; $i < $linenum; $i++) {
        //рисуем линии
        $color = imagecolorallocate($im, rand(0, 150), rand(0, 100), rand(0, 150));
        imageline($im, rand(0, 20), rand(1, 50), rand(150, 180), rand(1, 50), $color);
    }
    $color = imagecolorallocate($im, rand(0, 200), 0, rand(0, 200));
    imagettftext($im, $font_arr[$n]["size"], rand(-4, 4), rand(10, 45), rand(20, 35), $color, code_dir . $font_arr[$n]["fname"], generate_code());
    //накладываем код
    for ($i = 0; $i < $linenum; $i++) {
        $color = imagecolorallocate($im, rand(0, 255), rand(0, 200), rand(0, 255));
        imageline($im, rand(0, 20), rand(1, 50), rand(150, 180), rand(1, 50), $color);
    }
    ImagePNG($im);
    ImageDestroy($im);
    //ну вот и создано изображение!
}
开发者ID:VovaGurovskiy,项目名称:EnergoRemote,代码行数:41,代码来源:my_codegen.php

示例12: register

 public function register()
 {
     $this->form_validation->set_rules('name', 'Name', 'trim|required|xss_clean|is_unique[user.user_name]');
     $this->form_validation->set_rules('password', 'Password', 'trim|required|xss_clean');
     $this->form_validation->set_rules('email', 'Email', 'trim|required|xss_clean|valid_email|is_unique[user.user_email]');
     $this->form_validation->set_message('is_unique', 'The %s has been registered');
     if ($this->form_validation->run()) {
         $code = generate_code(12);
         $name = $this->input->post('name');
         $password = $this->input->post('password');
         $email = $this->input->post('email');
         $data = array('user_name' => $name, 'user_password' => enkripsi($password), 'user_email' => $email, 'user_status' => 'active', 'user_created_date' => now(), 'user_image' => 'default.jpg', 'user_registation_reff' => 'web');
         $iduser = $this->model_user->store($data);
         $row = $this->model_user->find($iduser);
         set_userdata('session_user', $row);
         set_userdata('user_level', 'member');
         $outs['msg'] = 'Registration success';
         $outs['flag'] = 1;
     } else {
         $outs['msg'] = validation_errors();
         $outs['flag'] = 0;
     }
     echo json_encode($outs);
 }
开发者ID:ridwanskaterock,项目名称:coc-ri-comunnity,代码行数:24,代码来源:User.php

示例13: add_data

 public function add_data()
 {
     // USE HTML PURIFIER
     // Build a nice little associative array for the data
     // Loop for each name to make sure multiple entries are dealt with.
     $warehouses = $this->input->post('name');
     $i = 0;
     $data = array();
     foreach ($warehouses as $warehouse) {
         $location2 = $this->input->post('location2');
         $location1 = $this->input->post('location1');
         $temp = array('name' => $warehouse, 'location1' => $location1[$i], 'location2' => $location2[$i]);
         $data[] = $temp;
         $i++;
     }
     // Validation
     $everythingGood = 1;
     // We believe in the good!
     foreach ($data as $datum) {
         $errors = $this->validate($datum);
         if ($errors === true) {
             // Check for redundancy.
             $there = $this->sharedDB_model->get('warehouse', array('id'), array('name' => $datum['name']));
             if (count($there) > 0) {
                 echo "<div class='alert alert-error fade in'>";
                 echo "<button type='button' class='close' data-dismiss='alert'>&times;</button><strong>Oh Snap! </strong>";
                 echo "The data you tried to enter already exist in the database.";
                 echo "!</div>\n";
                 die;
             }
             // Everything is good!
         } else {
             // There are errors. Set the error flag
             $everythingGood = $everythingGood * 0;
             // Show error message/s
             foreach ($errors as $error) {
                 echo "<div class='alert alert-error fade in'>";
                 echo "<button type='button' class='close' data-dismiss='alert'>&times;</button><strong>Oh Snap! </strong>";
                 echo $error;
                 echo "!</div>\n";
             }
             // Stop operation.
             break;
         }
     }
     // Check if everything is good and if it is, sanitize and filter everything.
     if ($everythingGood == 1) {
         // Filter rules
         $filterRules = array('name' => 'trim|sanitize_string', 'location1' => 'trim|sanitize_string', 'location2' => 'trim|sanitize_string');
         // Sanitize and filter data.
         $sanitizedData = array();
         foreach ($data as $datum) {
             $datum = $this->validation->sanitize($datum);
             $sanitizedData[] = $this->validation->filter($datum, $filterRules);
         }
         // Sanitization and all complete. Insert data into the database now.
         $dbGood = 1;
         foreach ($sanitizedData as $sanitizedDatum) {
             // Generate Code.
             $this->load->helper('generate_code');
             $sanitizedDatum['code'] = generate_code($this->router->class);
             if ($this->sharedDB_model->insert('warehouse', $sanitizedDatum) == 1) {
                 $dbGood = $dbGood * 1;
             } else {
                 $dbGood = $dbGood * 0;
             }
         }
         // Check if all data has been inserted into the database and show success message!
         if ($dbGood == 1) {
             echo "<div class='alert alert-success fade in'>";
             echo "<button type='button' class='close' data-dismiss='alert'>&times;</button><strong>Well Done! </strong>";
             echo "All warehouse successfully inserted into the database!";
             echo "!</div>\n";
         }
     }
 }
开发者ID:nurulimamnotes,项目名称:inventory-management,代码行数:76,代码来源:warehouse.php

示例14: add_download_package

 function add_download_package($package, $order_id)
 {
     // get customer stuff
     $customer = $this->go_cart->customer();
     if (!empty($customer['id'])) {
         $new_package['customer_id'] = $customer['id'];
     } else {
         $new_package['customer_id'] = 0;
     }
     $new_package['order_id'] = $order_id;
     $new_package['code'] = generate_code();
     // save master package record
     $this->db->insert('download_packages', $new_package);
     $package_id = $this->db->insert_id();
     // save the db data here
     $files_list = array();
     // use this to prevent inserting duplicates
     // in case a file is shared across products
     $ids = array();
     // build files records list
     foreach ($package as $product_list) {
         foreach ($product_list as $f) {
             if (!isset($ids[$f->file_id])) {
                 $file['package_id'] = $package_id;
                 $file['file_id'] = $f->file_id;
                 $file['link'] = md5($f->file_id . time() . $new_package['customer_id']);
                 // create a unique download key for each file
                 $files_list[] = $file;
             }
         }
     }
     $this->db->insert_batch('download_package_files', $files_list);
     // save the master record to include links in the order email
     $this->go_cart->save_order_downloads($new_package);
 }
开发者ID:Joncg,项目名称:eelly_cps_fx,代码行数:35,代码来源:digital_product_model.php

示例15: process_form

function process_form()
{
    // INITIAL DATA FETCHING
    global $name, $email, $cell, $yog, $mailings;
    // so that the show_form function can use these values later
    $name = htmlentities(ucwords(trim(strtolower($_POST['name']), ' \\-\'')));
    foreach (array('-', '\'') as $delimiter) {
        if (strpos($name, $delimiter) !== false) {
            $name = implode($delimiter, array_map('ucfirst', explode($delimiter, $name)));
        }
    }
    // forces characters after spaces, hyphens and apostrophes to be capitalized
    $name = preg_replace('/[\\s\']*\\-+[\\s\']*/', '-', $name);
    // removes hyphens not between two characters
    $name = preg_replace('/[\\s\\-]*\'+[\\s\\-]*/', '\'', $name);
    // removes apostrophes not between two characters
    $name = preg_replace('/\\s+/', ' ', $name);
    // removes multiple consecutive spaces
    $name = preg_replace('/\\-+/', '-', $name);
    // removes multiple consecutive hyphens
    $name = preg_replace('/\'+/', '\'', $name);
    // removes multiple consecutive apostrophes
    $email = htmlentities(strtolower($_POST['email']));
    $cell = htmlentities($_POST['cell']);
    $yog = $_POST['yog'];
    $pass = $_POST['pass1'];
    $mailings = '0';
    if ($_POST['mailings'] == 'Yes') {
        $mailings = '1';
    }
    // CHECK THAT THE NAME IS VALID
    if (($name = sanitize_username($name)) === false) {
        alert('Your name must have only letters, hyphens, apostrophes, and spaces, and be between 3 and 30 characters long', -1);
        show_form();
        return;
    }
    if (strpos($name, ' ') == false) {
        alert('Please enter both your first <span class="i">and</span> last name', -1);
        show_form();
        return;
    }
    // CHECK THAT THE EMAIL ADDRESS IS VALID
    if (!val('e', $email)) {
        alert('That\'s not a valid email address', -1);
        show_form();
        return;
    }
    // CHECK AND FORMAT CELL PHONE NUMBER
    if ($cell != '' && ($cell = format_phone_number($cell)) === false) {
        //Validate the format of the cell phone number (if it's not left blank)
        alert('That\'s not a valid cell phone number', -1);
        show_form();
        return;
    }
    // CHECK THAT THE YOG IS VALID
    $grade = intval(getGradeFromYOG($yog));
    if ($grade < 9 || $grade > 12) {
        alert('That is not a valid YOG (' . $grade . 'you have to be in high school)', -1);
        show_form();
        return;
    }
    // CHECK THAT THE PASSWORDS MATCH, MEET MINIMUM LENGTH
    if ($pass != $_POST['pass2']) {
        alert('The passwords that you entered do not match', -1);
        show_form();
        return;
    }
    if (strlen($pass) < 6) {
        alert('Please choose a password that has at least 6 characters', -1);
        show_form();
        return;
    }
    // CHECK THAT THEY ENTERED THE RECAPTCHA CORRECTLY
    // CURRENTLY BROKEN: NEED TO UPDATE RECAPTCHA
    /* 
    $recaptcha_msg = validate_recaptcha();
    if ($recaptcha_msg !== true) {
    	alert($recaptcha_msg, -1);
    	show_form();
    	return;
    }
    */
    // CHECK THAT AN ACCOUNT WITH THAT EMAIL DOES NOT ALREADY EXIST
    // this is done *after* checking the reCaptcha to prevent bots from harvesting our email
    // addresses via a brute-force attack.
    if (DBExt::queryCount('users', 'LOWER(email)=LOWER(%s)', $email) != 0) {
        alert('An account with that email address already exists', -1);
        show_form();
        return;
    }
    // CHECK THAT AN ACCOUNT WITH THE SAME NAME IN THE SAME GRADE DOES NOT EXIST
    // - with the exception that if it's permissions = 'E', they probably mistyped their email and are redoing it.
    if (DBExt::queryCount('users', 'LOWER(name)=%s AND yog=%i AND permissions!="E"', strtolower($name), $yog) != 0) {
        alert('An account in your grade with that name already exists', -1);
        show_form();
        return;
    }
    // ** All information has been validated at this point **
    $verification_code = generate_code(5);
    // for verifying ownership of the email address
//.........这里部分代码省略.........
开发者ID:lhsmath,项目名称:lhsmath.org,代码行数:101,代码来源:Register.php


注:本文中的generate_code函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。