function add() { $this->form_validation->set_rules("username", "Username", "required|max_length[25]|callback_checkUser"); $this->form_validation->set_rules("password", "Password", "required|matches[repassword]"); $this->form_validation->set_rules("gender", "Gender", "required"); $data['error'] = ""; if ($this->form_validation->run() == FALSE) { $this->my_layout->view("backend/user/add_view", array("error" => "")); } else { $salt = create_random_string(5); $add = array("username" => $this->input->post("username"), "password" => md5($this->input->post("password")), "level" => $_POST['level'], "gender" => $_POST['gender']); //--- Gui mail kich hoat neu add thanh cong $message = ""; $mail = array(); if ($this->muser->addUser($add)) { $userid = mysql_insert_id(); $link_active = base_url() . "home/user/active/?userid=" . $userid . "&key=" . md5($salt); $message = "Please follow this link to active your acount <br/>" . ($message .= "Link : <a href=" . $link_active . ">" . $link_active . "</a><br/>"); $message .= "username : "******"<br/>"; $message .= "password : "******"password"); $mail = array("to_receiver" => $add['email'], "message" => $message); $this->load->library("my_email"); $this->my_email->config($mail); $this->my_email->sendmail(); redirect(base_url() . "Cadmin/user"); } $this->my_layout->view("backend/user/add_view", $data); } }
/** * Process password forgotten * * @access public * @return void */ public function process() { $email_address = $this->input->post('email_address'); if (validate_email_address($email_address)) { //load model $this->load->model('account_model'); $data = $this->account_model->get_data($email_address); if ($data !== NULL) { $password = create_random_string(config('ACCOUNT_PASSWORD')); if ($this->account_model->save_password($data['customers_id'], $password)) { $this->load->library('email_template'); $email = $this->email_template->get_email_template('password_forgotten'); $email->set_data($data['customers_firstname'], $data['customers_lastname'], getenv('REMOTE_ADDR'), $password, $data['customers_gender'], $data['customers_email_address']); $email->build_message(); $email->send_email(); $this->message_stack->add_session('login', lang('success_password_forgotten_sent'), 'success'); redirect('account/login'); } } else { $this->message_stack->add('password_forgotten', lang('error_password_forgotten_no_email_address_found')); } } else { $this->message_stack->add('password_forgotten', lang('error_password_forgotten_no_email_address_found')); } $this->template->build('account/password_forgotten'); }
$symbol_count++; if ($symbol_count == $word_count) { $result .= ' '; $symbol_count = 0; $new_word = true; } } return $result; } if ($action == 'update') { $need_update = false; $last_version_file = fopen("http://cutephp.com/cutenews/latest_version.php", "r"); ob_start(); fpassthru($last_version_file); list($last_version, $last_version_name) = explode('|', ob_get_clean()); if ($last_version > $config_version_id) { $need_update = true; } if ($need_update) { $update_key = base64_encode(create_random_string(50, 7)); $update_temp = fopen(SERVDIR . '/cdata/update_temp.php', "w"); fwrite($update_temp, "<?php\n\$update_key='" . $update_key . "';\n?>"); fclose($update_temp); setcookie('update', $update_key, time() + 60 * 60, '/'); echoheader('info', lang("Update status"), make_breadcrumbs('main/options=options/Update Status')); echo proc_tpl('update/status'); echofooter(); } else { msg('info', lang('Update status'), lang('No update: your revision is the latest one')); } }
<?php // Check to make sure that the basic security variable has been set // thus ensuring tht the file is not being loaded directly. if (!defined('_SECURITY_BASIC')) { die(''); } // Create the map code $vc_MapCode = create_random_string(32); // Create the new record $query = "INSERT INTO " . _DB_NAME . "." . _DB_PREFIX . "_Map\n ( pk_ID,\n fk_UserID,\n vc_MapCode,\n vc_Name,\n dt_Created,\n dt_Updated )\n VALUES\n ( '',\n '{$UserID}',\n '{$vc_MapCode}',\n 'Some Map',\n NOW(),\n NOW() )"; $result = mysql_query($query); // Redirect the user to the new map header("Location: index.php?module=Map&op=edit&MapID={$vc_MapCode}");
function prepareFileName($name, $type = '') { return substr(preg_replace('/[\\W]+/', '_', $name), 0, 120) . '_' . create_random_string(10, 'digits') . $type; }
function fg_password() { //--- Neu Login thi khong duoc vao trang nay if ($this->my_auth->is_Login()) { redirect(base_url() . "Chome/user"); exit; } $this->form_validation->set_rules("email", "Email", "required|valid_email|callback_checkEmailForgot"); $data['error'] = ""; if ($this->form_validation->run() == FALSE) { $this->load->view("frontend/fg_password", $data); } else { $email = $this->input->post("email"); $info = $this->muser->getInfoByEmail($email); $message = ""; if ($info['active'] == 1) { // reset password cho user $password = create_random_string(5); $reset = array("password" => md5($password)); $this->muser->updateUser($reset, $info['userid']); //--- Gui mail cho user $message = "Please login with :<br/>"; $message .= "username :"******"<br/>"; $message .= "password:"******"to_receiver" => $email, "message" => $message); $this->load->library("my_email"); $this->my_email->config($mail); $this->my_email->sendmail(); $this->session->set_userdata(array($this->_fgpassword => TRUE)); redirect(base_url() . "Chome/user/fg_complete"); } else { $data['error'] = "You hasn't been actived your account, please check your email again !"; } $this->load->view("frontend/fg_password", $data); } }
/** * Generate Cart ID * * @access public * @param $length * @return string */ function generate_cart_id($length = 5) { return create_random_string($length, 'digits'); }
//increment valid number $nrValidFilesUploads++; } //endif valid upload } //endfor nrUserUploads if (count($validFilesUploadsArray)) { $file_input = $validFilesUploadsArray[0]['file_input']; $file_input_thumb = $validFilesUploadsArray[0]['file_input_thumb']; } else { $file_input = $file_input_thumb = ''; } //get location reverse geocode (via Google) $location_reverse = getReverseGeocode($coord_lat, $coord_lon); //generate random validation code $validation_code = create_random_string(32); //Insert Sesizare insertIntoTable("INSERT INTO sesizari SET \n\t\t\t\t\t\t\t sesizare_titlu = :sesizare_titlu, \n\t\t\t\t\t\t\t sesizare_descriere = :sesizare_descriere,\n\t\t\t\t\t\t\t data_ora = :data_ora,\n\t\t\t\t\t\t\t coord_lon = :coord_lon,\n\t\t\t\t\t\t\t coord_lat = :coord_lat,\n\t\t\t\t\t\t\t location_search = :location_search,\n\t\t\t\t\t\t\t location_reverse = :location_reverse,\n\t\t\t\t\t\t\t file_input = :file_input,\n\t\t\t\t\t\t\t file_input_thumb = :file_input_thumb,\n\t\t\t\t\t\t\t personal_nume = :personal_nume,\n\t\t\t\t\t\t\t personal_prenume = :personal_prenume,\n\t\t\t\t\t\t\t personal_email = :personal_email,\n\t\t\t\t\t\t\t personal_telefon = :personal_telefon,\n\t\t\t\t\t\t\t added_at = :added_at,\n\t\t\t\t\t\t\t validation_code = :validation_code\n\t\t\t\t\t\t\t ", array("sesizare_titlu" => $titlu, "sesizare_descriere" => nl2br($descriere), "data_ora" => $data_ora, "coord_lon" => $coord_lon, "coord_lat" => $coord_lat, "location_search" => $location_search, "location_reverse" => $location_reverse, "file_input" => $file_input, "file_input_thumb" => $file_input_thumb, "personal_nume" => $nume, "personal_prenume" => $prenume, "personal_email" => $email, "personal_telefon" => $telefon, "added_at" => date("Y-m-d H:i:s"), "validation_code" => $validation_code)); $sesizareId = $config['dbConnection']->lastInsertId(); //insert $validFilesUploadsArray[ for ($i = 0; $i < count($validFilesUploadsArray); $i++) { insertIntoTable("INSERT INTO mm_sesizari_images SET sesizare_id = :sesizare_id, file_input = :file_input, file_input_thumb = :file_input_thumb ", array("sesizare_id" => $sesizareId, "file_input" => $validFilesUploadsArray[$i]['file_input'], "file_input_thumb" => $validFilesUploadsArray[$i]['file_input_thumb'])); } //endfor $validFilesUploadsArray //insert $linkuri_sursa for ($i = 0; $i < count($linkuri_sursa); $i++) { if (strlen($linkuri_sursa[$i])) { insertIntoTable("INSERT INTO mm_sesizari_linkuri SET sesizare_id = :sesizare_id, link_sursa = :link_sursa ", array("sesizare_id" => $sesizareId, "link_sursa" => $linkuri_sursa[$i])); } } //endfor $linkuri_sursa
function get_queries() { global $data, $db_version, $time; $fp = fopen('PHPDevShell-db' . $db_version . '-complete.sql', 'r'); $queries = stream_get_contents($fp); fclose($fp); if (!empty($_POST['sample-data'])) { $fp = fopen('PHPDevShell-db-sample.sql', 'r'); $queries .= stream_get_contents($fp); fclose($fp); } $queries = preg_replace('/pds_core_/', $data['db_prefix'] . 'core_', $queries); $query = explode(';', $queries); array_pop($query); $admin_password = md5($data['admin_password']); $crypt_key = create_random_string(30); // Other queries. $query[] = 'REPLACE INTO `' . $data['db_prefix'] . "core_settings` VALUES ('PHPDevShell_crypt_key', '" . $crypt_key . "', '');"; $query[] = 'REPLACE INTO `' . $data['db_prefix'] . "core_settings` VALUES ('PHPDevShell_from_email', '" . $data['admin_email'] . "', '');"; $query[] = 'REPLACE INTO `' . $data['db_prefix'] . "core_settings` VALUES ('PHPDevShell_scripts_name_version', '" . $data['application_name'] . "', '');"; $query[] = 'REPLACE INTO `' . $data['db_prefix'] . "core_settings` VALUES ('PHPDevShell_setting_admin_email', '" . $data['admin_email'] . "', '');"; $query[] = 'REPLACE INTO `' . $data['db_prefix'] . "core_users` VALUES ('1', 'Root User', '" . $data['admin_username'] . "', '" . $admin_password . "', '" . $data['admin_email'] . "', '1', '1', '" . $time . "', 'en', 'UTC', 'US');"; // Update version. $query[] = 'REPLACE INTO `' . $data['db_prefix'] . "core_plugin_activation` VALUES ('AdminTools', 'install', '" . $db_version . "', '1');"; return $query; }