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


PHP random_string函数代码示例

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


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

示例1: blockem_prepare_body

function blockem_prepare_body(&$a, &$b)
{
    if (!local_user()) {
        return;
    }
    $words = null;
    if (local_user()) {
        $words = get_pconfig(local_user(), 'blockem', 'words');
    }
    if ($words) {
        $arr = explode(',', $words);
    } else {
        return;
    }
    $found = false;
    if (count($arr)) {
        foreach ($arr as $word) {
            if (!strlen(trim($word))) {
                continue;
            }
            if (link_compare($b['item']['author-link'], $word)) {
                $found = true;
                break;
            }
        }
    }
    if ($found) {
        $rnd = random_string(8);
        $b['html'] = '<div id="blockem-wrap-' . $rnd . '" class="fakelink" onclick=openClose(\'blockem-' . $rnd . '\'); >' . sprintf(t('Blocked %s - Click to open/close'), $word) . '</div><div id="blockem-' . $rnd . '" style="display: none; " >' . $b['html'] . '</div>';
    }
}
开发者ID:robhell,项目名称:friendica-addons,代码行数:31,代码来源:blockem.php

示例2: register

 public function register()
 {
     $this->form_validation->set_rules('reg_username', 'Username', 'required|trim|alpha_numeric|min_length[6]|max_length[50]|xss_clean|strtolower|callback_check_new_username');
     $this->form_validation->set_rules('reg_name', 'Name', 'trim|min_length[6]|max_length[50]|xss_clean');
     $this->form_validation->set_rules('reg_email', 'Email Address', 'trim|min_length[6]|max_length[50]|valid_email|xss_clean|callback_check_new_email');
     $this->form_validation->set_rules('reg_password', 'Password', 'required|trim|min_length[6]|max_length[50]|xss_clean');
     $this->form_validation->set_rules('reg_conf_password', 'Password Confirmation', 'required|trim|min_length[6]|max_length[50]|matches[reg_password]|xss_clean');
     if ($this->form_validation->run() == FALSE) {
         $this->load->view('view_register');
     } else {
         // we are good. we will process the form
         extract($_POST);
         $this->user_model->register_user($reg_username, $reg_password, $reg_name, $reg_email);
         // Send activation email
         $this->load->library('email');
         $this->email->from('doe9496@gmail.com', 'al');
         $this->email->to($reg_email);
         $this->email->subject('Registration Confirmation');
         $this->load->helper('string');
         $activation_code = random_string('alnum', 10);
         $this->email->message('Click the link below to activate your account' . anchor('http://localhost/codetwo/index.php/user/confirmation_activation/' . $activation_code, 'Confirmation Register'));
         $this->email->send();
         echo "Activation email has been sent to {$reg_email}<br>";
         echo "You have successfully registered!";
     }
 }
开发者ID:halnahas,项目名称:ci,代码行数:26,代码来源:user.php

示例3: respaldar

 public function respaldar()
 {
     $id_perfil = $this->session->userdata('id_perfil');
     switch ($id_perfil) {
         case 1:
             $this->load->dbutil();
             $nom_bd = 'utm';
             //Las preferencias de copia de seguridad son establecidas enviando un arreglo de valores como primer parámetro de la función "backup".
             $prefs = array('ignore' => array(), 'format' => 'zip', 'filename' => 'utm.sql', 'add_drop' => TRUE, 'add_insert' => TRUE, 'newline' => "\n");
             if ($this->dbutil->database_exists($nom_bd)) {
                 // Crea una copia de seguridad de toda la base de datos y la asigna a una variable
                 $copia_de_seguridad =& $this->dbutil->backup($prefs);
                 $nombre = 'respaldo_' . date('d') . date('m') . date('Y') . '_' . random_string('alpha', 4) . random_string('numeric', 3) . '.zip';
                 // Carga el asistente de archivos y escribe el archivo en su servidor
                 $this->load->helper('file');
                 write_file('./uploads/respaldos/' . $nombre, $copia_de_seguridad);
                 // Carga el asistente de descarga y envía el archivo a su escritorio
                 /*
                                                 $this->load->helper('download');
                                                 force_download('copia_de_seguridad.gz', $copia_de_seguridad);          
                 */
                 echo TRUE;
             } else {
                 echo '<span class="error">No se realizar la salva de la base de datos</span>';
             }
             //redirect('usuarios');
             break;
         default:
             echo '<span class="error">No se realizar la salva de la base de datos</span>';
             break;
     }
 }
开发者ID:estrategasdigitales,项目名称:Alakazam,代码行数:32,代码来源:respaldo.php

示例4: img_func

function img_func($atts, $content = '')
{
    $id = random_string('alnum', 16);
    $sd = '[/col]';
    $string = "<div class='col-sm-{$atts['foo']} move' id='{$id}' mwidth='{$atts['foo']}'> \n\t\t\t<header class='panel-heading font-bold'> \n\t\t\t\t<span style='color:#fff;'>ff</span> \n\t\t\t\t<div class='handle fa fa-arrows'></div> \n\t\t\t\t<div class='shrink fa fa-minus-square'></div> \n\t\t\t\t<div class='grow fa fa-plus-square'></div> \n\t\t\t\t<div class='remove fa fa-trash-o'></div>\n\t\t\t</header> \n\t\t\t<section class='panel'> \n\t\t\t\t<div class='panel-body'> \n\t\t\t\t\t<div class='form-group'> \n\t\t\t\t\t\t<label>Content</label> \n\t\t\t\t\t\t <img class='img-responsive' src='{$content}' alt='image' />\n\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t<div class='image'></div>\n\t\t\t\t\t</div> \n\t\t\t\t\t<div class='shorttag' id='shorttag-{$id}' style='display:none;'>[col foo='{$atts['foo']}'][img src='{$content}'][/img]{$sd}</div> \n\t\t\t\t<button type='submit' class='btn btn-info btn-s-xs pp-img' mid='{$id}' mpath='{$content}'><strong>Save</strong></button> \n\t\t\t\t</div> \n\n\t\t\t</section>\n\t\t </div>";
    return $string;
}
开发者ID:freeztime,项目名称:ignitedcms-pro,代码行数:7,代码来源:my_codes.php

示例5: olvido_form

 public function olvido_form()
 {
     $this->form_validation->set_rules('email', 'E-Mail', 'required|callback_check_usuario_existe');
     $respuesta = new stdClass();
     if ($this->form_validation->run() == TRUE) {
         $random = random_string('alnum', 16);
         $usuario = Doctrine::getTable('UsuarioBackend')->findOneByEmail($this->input->post('email'));
         $usuario->reset_token = $random;
         $usuario->save();
         $cuenta = Cuenta::cuentaSegunDominio();
         if (is_a($cuenta, 'Cuenta')) {
             $this->email->from($cuenta->nombre . '@chilesinpapeleo.cl', $cuenta->nombre_largo);
         } else {
             $this->email->from('simple@chilesinpapeleo.cl', 'Simple');
         }
         $this->email->to($usuario->email);
         $this->email->subject('Reestablecer contraseña');
         $this->email->message('<p>Haga click en el siguiente link para reestablecer su contraseña:</p><p><a href="' . site_url('backend/autenticacion/reestablecer?id=' . $usuario->id . '&reset_token=' . $random) . '">' . site_url('autenticacion/reestablecer?id=' . $usuario->id . '&reset_token=' . $random) . '</a></p>');
         $this->email->send();
         $this->session->set_flashdata('message', 'Se le ha enviado un correo con instrucciones de como reestablecer su contraseña.');
         $respuesta->validacion = TRUE;
         $respuesta->redirect = site_url('backend/autenticacion/login');
     } else {
         $respuesta->validacion = FALSE;
         $respuesta->errores = validation_errors();
     }
     echo json_encode($respuesta);
 }
开发者ID:chileindica,项目名称:SIMPLE,代码行数:28,代码来源:autenticacion.php

示例6: SaveAttachment

 public function SaveAttachment()
 {
     $this->load->helper(array('string', 'url', 'file', 'form'));
     $root = 'files/unitee/compras/';
     $dir = isset($_REQUEST['directory']) ? $_REQUEST['directory'] : NULL;
     $name = random_string("md5");
     if (!is_null($dir)) {
         if (!file_exists(FCPATH . $root . $dir)) {
             if (!mkdir(FCPATH . $root . $dir, 0775)) {
                 $dir = "";
             }
         }
     }
     $this->load->library("base_upload");
     $this->base_upload->set_path("./" . $root . ($dir != '' ? $dir . "/" : ''));
     $this->base_upload->set_filename(array($name));
     $this->base_upload->Do_MultiUpload('files');
     $f = array();
     $f[0]['name'] = $_FILES['files']['name'];
     $f[0]['size'] = $_FILES['files']['size'];
     $f[0]['url'] = FCPATH . $root . ($dir != '' ? $dir . "/" : '') . $name;
     $f[0]['thumbnailUrl'] = FCPATH . $root . ($dir != '' ? $dir . "/" : '') . $name;
     $f[0]['deleteUrl'] = NULL;
     $f[0]['deleteType'] = NULL;
     $f[0]['error'] = NULL;
     $f[0]['data'] = json_encode(array("name" => $_FILES['files']['name'], "document" => $name, "directory" => $dir));
     $this->output->set_content_type('application/json')->set_output(json_encode(array('files' => $f)));
 }
开发者ID:prosenjit-itobuz,项目名称:Unitee,代码行数:28,代码来源:Buy.php

示例7: authenticate

 function authenticate()
 {
     $username = $this->input->post('username', TRUE);
     $password = $this->input->post('password', TRUE);
     if ($user_info = $this->twfunctions->getAuthenticateData($username)) {
         $row = $user_info[0];
         if (($username == $row->username || $username == $row->email) && md5($password) == $row->password) {
             $access_token = random_string('alnum', 32);
             if ($this->twfunctions->setApiLoginAccessToken($row->id_users, $access_token)) {
                 $user_session = $row->session_id . '_' . $access_token;
                 if ($this->twfunctions->set_login_log($row->id_users)) {
                 }
                 $session_data = array('username' => $row->username, 'session_id' => $user_session, 'logged_in' => TRUE);
                 $this->session->set_userdata($session_data);
                 //redirect('dashboard');
                 echo "{\"response\":{\"success\":true,\"message\":\"Successfully Logged in\",\"logged_in\":true,\"user_id\":" . $row->id_users . ",\"username\":\"" . $row->username . "\",\"access_token\":\"" . $access_token . "\"}}";
                 return;
             } else {
                 //$this->session->set_flashdata('alert', 'Error');
                 //redirect('login');
                 echo "{\"response\":{\"success\":true,\"message\":\"Something went wrong\",\"logged_in\":false}}";
                 return;
             }
         } else {
             //$this->session->set_flashdata('alert', 'Invalid password');
             //redirect('login');
             echo "{\"response\":{\"success\":true,\"message\":\"Invalid password\",\"logged_in\":false}}";
             return;
         }
     }
     //$this->session->set_flashdata('alert', 'Not user or not activated.');
     //redirect('login');
     echo "{\"response\":{\"success\":true,\"message\":\"Not user or not activated\",\"logged_in\":false}}";
     return;
 }
开发者ID:MortalROs,项目名称:social,代码行数:35,代码来源:landing.php

示例8: refresh_token

 /**
  * Refresh the user's token
  *
  * This should generally be used any time you need to create a new token
  * for a user. Definitely call this on login and logout.
  *
  * @return String new token
  */
 public function refresh_token()
 {
     $token = random_string('encrypt');
     $this->backend->delete_token();
     $this->backend->store_token($token);
     return $token;
 }
开发者ID:realfluid,项目名称:umbaugh,代码行数:15,代码来源:Csrf.php

示例9: resetpassword

 private function resetpassword($user)
 {
     date_default_timezone_set('Asia/Jakarta');
     $this->load->helper('string');
     $password = random_string('alnum', 16);
     $this->load->library('email');
     $this->email->from('keykaka.kurniawan@gmail.com', 'Administrator');
     $this->email->to($user->user_email);
     $this->email->subject('Password reset');
     $this->email->message('You have requested the new password, Here is your new password:' . $password . ' for login into Adneys Shop');
     $sendemail = $this->email->send();
     if ($sendemail) {
         $this->db->where('id_user', $user->id_user);
         //        $this->db->update('users_tabel', array('user_password' => MD5($password), 'confirm_password' => MD5($password)));
         $this->db->update('users_tabel', array('user_password' => $password, 'confirm_password' => $password));
         $data['title'] = "Login | Adney's Shop";
         $this->session->set_flashdata('message', '<div class="alert alert-success">Your Password has been reset and has been sent to email id:' . $user->user_email . '</div>');
         redirect('public/logins', $data);
     } else {
         show_error($this->email->print_debugger());
         $data['title'] = "Login | Adney's Shop";
         $this->session->set_flashdata('message', '<div class="alert alert-danger">Gagal Mengirimkan Kode Reset password ke email anda:' . $user->user_email . '</div>');
         redirect('public/logins', $data);
     }
 }
开发者ID:keykurniawan,项目名称:sikomper,代码行数:25,代码来源:logins.php

示例10: generate_mdp

 function generate_mdp()
 {
     $this->load->helper('security');
     $this->load->helper('string');
     $mdp = MD5(random_string('alnum', 12));
     return $mdp;
 }
开发者ID:Amnesia80,项目名称:gico,代码行数:7,代码来源:user.php

示例11: new_comment

 function new_comment($data)
 {
     // Look and see if the email address already exists in the users
     // table, if it does, return the primary key, if not create them
     // a user account and return the primary key
     $usr_email = $data['usr_email'];
     $query = $this->db->select('*')->from('users')->where('usr_email', $usr_email);
     $result = $this->db->get($query);
     if ($result->num_rows() > 0) {
         // if we arrive here in the code, then the email address is obv already
         // in the database, so we grap the users' primary key and store it in $data['usr_id']
         foreach ($result->result() as $rows) {
             $data['usr_id'] = $rows->usr_id;
         }
     } else {
         // create the user and return the priamry key
         $password = random_string('alnum', 16);
         $hash = $this->encrypt->sha1($password);
         $user_data = array('usr_email' => $data['usr_email'], 'usr_name' => $data['usr_name'], 'usr_is_acctive' => '1', 'usr_level' => '1', 'usr_hash' => $hash);
         if ($this->db->insert('users' . $user_data)) {
             $data['usr_id'] = $this->db->insert_id();
         }
     }
     $comment_data = array('cm_body' => $data['cm_body'], 'ds_id' => $data['ds_id'], 'cm_is_active' => '1', 'usr_id' => $data['usr_id']);
     if ($this->db->insert('comments', $comment_data)) {
         return $this->db->insert_id();
     } else {
         return false;
     }
 }
开发者ID:ann-xvii,项目名称:discussion-forum,代码行数:30,代码来源:comments_model.php

示例12: _init

 public function _init()
 {
     $this->load->model("proveedor/view_proveedor", "prov");
     $this->load->model("productos/view_producto", "prod");
     $this->load->helper(array("form", "string"));
     $this->load->view("compra/compra_new", array("prov" => $this->prov->get_Allproviders(), "prod" => $this->prod->get_products(), "upload_dir" => random_string()));
 }
开发者ID:prosenjit-itobuz,项目名称:Unitee,代码行数:7,代码来源:New_compra.php

示例13: lostpass_content

function lostpass_content(&$a)
{
    if (x($_GET, 'verify')) {
        $verify = $_GET['verify'];
        $r = q("SELECT * FROM account WHERE account_reset = '%s' LIMIT 1", dbesc($verify));
        if (!$r) {
            notice(t("Request could not be verified. (You may have previously submitted it.) Password reset failed.") . EOL);
            goaway(z_root());
            return;
        }
        $aid = $r[0]['account_id'];
        $email = $r[0]['account_email'];
        $new_password = autoname(6) . mt_rand(100, 9999);
        $salt = random_string(32);
        $password_encoded = hash('whirlpool', $salt . $new_password);
        $r = q("UPDATE account SET account_salt = '%s', account_password = '%s', account_reset = '', account_flags = (account_flags & ~%d) where account_id = %d", dbesc($salt), dbesc($password_encoded), intval(ACCOUNT_UNVERIFIED), intval($aid));
        if ($r) {
            $tpl = get_markup_template('pwdreset.tpl');
            $o .= replace_macros($tpl, array('$lbl1' => t('Password Reset'), '$lbl2' => t('Your password has been reset as requested.'), '$lbl3' => t('Your new password is'), '$lbl4' => t('Save or copy your new password - and then'), '$lbl5' => '<a href="' . $a->get_baseurl() . '">' . t('click here to login') . '</a>.', '$lbl6' => t('Your password may be changed from the <em>Settings</em> page after successful login.'), '$newpass' => $new_password, '$baseurl' => $a->get_baseurl()));
            info("Your password has been reset." . EOL);
            $email_tpl = get_intltext_template("passchanged_eml.tpl");
            $message = replace_macros($email_tpl, array('$sitename' => $a->config['sitename'], '$siteurl' => $a->get_baseurl(), '$username' => sprintf(t('Site Member (%s)'), $email), '$email' => $email, '$new_password' => $new_password, '$uid' => $newuid));
            $subject = email_header_encode(sprintf(t('Your password has changed at %s'), get_config('system', 'sitename')), 'UTF-8');
            $res = mail($email, $subject, $message, 'From: ' . 'Administrator@' . $_SERVER['SERVER_NAME'] . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" . 'Content-transfer-encoding: 8bit');
            return $o;
        }
    } else {
        $tpl = get_markup_template('lostpass.tpl');
        $o .= replace_macros($tpl, array('$title' => t('Forgot your Password?'), '$desc' => t('Enter your email address and submit to have your password reset. Then check your email for further instructions.'), '$name' => t('Email Address'), '$submit' => t('Reset')));
        return $o;
    }
}
开发者ID:TamirAl,项目名称:hubzilla,代码行数:32,代码来源:lostpass.php

示例14: datos

 function datos($campo_id, $etapa_id)
 {
     $etapa = Doctrine::getTable('Etapa')->find($etapa_id);
     if (UsuarioSesion::usuario()->id != $etapa->usuario_id) {
         echo 'Usuario no tiene permisos para subir archivos en esta etapa';
         exit;
     }
     $campo = Doctrine_Query::create()->from('Campo c, c.Formulario.Pasos.Tarea.Etapas e')->where('c.id = ? AND e.id = ?', array($campo_id, $etapa_id))->fetchOne();
     if (!$campo) {
         echo 'Campo no existe';
         exit;
     }
     // list of valid extensions, ex. array("jpeg", "xml", "bmp")
     $allowedExtensions = array('gif', 'jpg', 'png', 'pdf', 'doc', 'docx', 'zip', 'rar', 'ppt', 'pptx', 'xls', 'xlsx', 'mpp', 'vsd');
     if (isset($campo->extra->filetypes)) {
         $allowedExtensions = $campo->extra->filetypes;
     }
     // max file size in bytes
     $sizeLimit = 20 * 1024 * 1024;
     $uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
     $result = $uploader->handleUpload('uploads/datos/');
     if (isset($result['success'])) {
         $file = new File();
         $file->tramite_id = $etapa->Tramite->id;
         $file->filename = $result['file_name'];
         $file->tipo = 'dato';
         $file->llave = strtolower(random_string('alnum', 12));
         $file->save();
         $result['id'] = $file->id;
         $result['llave'] = $file->llave;
     }
     // to pass data through iframe you will need to encode all html tags
     echo htmlspecialchars(json_encode($result), ENT_NOQUOTES);
 }
开发者ID:chileindica,项目名称:SIMPLE,代码行数:34,代码来源:uploader.php

示例15: forgotpassword

 public function forgotpassword()
 {
     $data = '';
     $post = $this->input->post();
     if ($post) {
         $error = array();
         $e_flag = 0;
         if (!valid_email(trim($post['email'])) && trim($post['email']) == '') {
             $error['email'] = 'Please enter email.';
             $e_flag = 1;
         }
         if ($e_flag == 0) {
             $where = array('email' => trim($post['email']), 'role' => 'admin');
             $user = $this->common_model->selectData(ADMIN, '*', $where);
             if (count($user) > 0) {
                 $newpassword = random_string('alnum', 8);
                 $data = array('password' => md5($newpassword));
                 $upid = $this->common_model->updateData(ADMIN, $data, $where);
                 $emailTpl = $this->load->view('email_templates/admin_forgot_password', array('username' => $user[0]->name, 'password' => $newpassword), true);
                 $ret = sendEmail($user[0]->email, SUBJECT_LOGIN_INFO, $emailTpl, FROM_EMAIL, FROM_NAME);
                 if ($ret) {
                     $flash_arr = array('flash_type' => 'success', 'flash_msg' => 'Login details sent successfully.');
                 } else {
                     $flash_arr = array('flash_type' => 'error', 'flash_msg' => 'An error occurred while processing.');
                 }
                 $data['flash_msg'] = $flash_arr;
             } else {
                 $error['email'] = "Invalid email address.";
             }
         }
         $data['error_msg'] = $error;
     }
     $this->load->view('index/forgotpassword', $data);
 }
开发者ID:niravpatel2008,项目名称:ubiquitous-octo-tatertot,代码行数:34,代码来源:index.php


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