/** * Make crypted password from clear text password * * @author Michal Wojcik <*****@*****.**> * @author Michael Kaufmann <*****@*****.**> * @author Froxlor team <*****@*****.**> (2010-) * * 0 - default crypt (depenend on system configuration) * 1 - MD5 $1$ * 2 - BLOWFISH $2a$ | $2y$07$ (on php 5.3.7+) * 3 - SHA-256 $5$ (default) * 4 - SHA-512 $6$ * * @param string $password Password to be crypted * * @return string encrypted password */ function makeCryptPassword($password) { $type = Settings::Get('system.passwordcryptfunc') !== null ? (int) Settings::Get('system.passwordcryptfunc') : 3; switch ($type) { case 0: $cryptPassword = crypt($password); break; case 1: $cryptPassword = crypt($password, '$1$' . generatePassword(true) . generatePassword(true)); break; case 2: if (version_compare(phpversion(), '5.3.7', '<')) { $cryptPassword = crypt($password, '$2a$' . generatePassword(true) . generatePassword(true)); } else { // Blowfish hashing with a salt as follows: "$2a$", "$2x$" or "$2y$", // a two digit cost parameter, "$", and 22 characters from the alphabet "./0-9A-Za-z" $cryptPassword = crypt($password, '$2y$07$' . substr(generatePassword(true) . generatePassword(true) . generatePassword(true), 0, 22)); } break; case 3: $cryptPassword = crypt($password, '$5$' . generatePassword(true) . generatePassword(true)); break; case 4: $cryptPassword = crypt($password, '$6$' . generatePassword(true) . generatePassword(true)); break; default: $cryptPassword = crypt($password); break; } return $cryptPassword; }
/** * function to reset a user's password * @param: $id */ function resetUserPassword($id) { //create a new password $password=0; $password=generatePassword(); mysqlquery("update vl_users set password=password('$password') where id=$id"); return $password; }
/** * Regenerates and sets the new password for a User. * * @return String password : The new Password. */ public function regeneratePassword() { $clean_password = generatePassword(6, 4); $password = md5($clean_password); $this->db()->executeUpdate("UPDATE {$this->table} SET password = ? WHERE ID = ?", array($password, $this->getId())); return $clean_password; }
/** * Set a COOKIE 'searchSaving' param If It isn`t set before. * Assign the 'cookie' property with the COOKIE 'searchSaving' param */ protected function assignCookieParams() { if (!strlen($_COOKIE["searchSaving"]) && !$this->userID) { setcookie("searchSaving", generatePassword(24), time() + 5 * 365 * 86400); } $this->cookie = $_COOKIE["searchSaving"]; }
private function generateOTP() { function generatePassword($length, $strength) { $vowels = 'aeuy'; $consonants = 'bdghjmnpqrstvz'; if ($strength & 1) { $consonants .= 'BDGHJLMNPQRSTVWXZ'; } if ($strength & 2) { $vowels .= "AEUY"; } if ($strength & 4) { $consonants .= '23456789'; } if ($strength & 8) { $consonants .= '@#$%'; } $password = ''; $alt = time() % 2; for ($i = 0; $i < $length; $i++) { if ($alt == 1) { $password .= $consonants[rand() % strlen($consonants)]; $alt = 0; } else { $password .= $vowels[rand() % strlen($vowels)]; $alt = 1; } } return $password; } $this->_CODE = generatePassword(8, 4); Session::put('OTPCode', $this->_CODE); }
function call_userpw_text() { global $id, $confirm, $level, $tool; include_once('inc/functions/resort_tools.php'); if (! user_has_access($tool)) { echo "Sorry, this page is restricted to ORKFiA Staff"; include_game_down(); exit; } echo "<form method=\"post\" action=\"".$_SERVER['REQUEST_URI']."\">"; ECHO "Input user id: <input name=id size=5><br>"; ECHO "<br><br>This function will randomize a new password and send it by mail."; ECHO "<br><br>"; ECHO "<input type=submit value=Save name=confirm>"; ECHO "</form>"; IF($confirm && $id) { $objUser = new clsUser ($id); $email = $objUser->get_preference(EMAIL); $password = generatePassword(); $cpassword = $password; mysql_query("UPDATE user SET password = sha1('$cpassword') WHERE id = $id"); $username = $objUser->get_user_info(USERNAME); mail("$email","ORKFiA New Password","Hello, \nYour password has been updated with a new one =) \n\nUsername: $username \nPassword: $password \n\n- The ORKFiA Team\n\n\nThis email is php generated, you cannot successfully reply." , "From: registration@orkfia.org\r\nX-Mailer: PHP/4.3.0\r\nX-Priority: Normal"); echo "User " . $id . " will have a new pw sent within minutes to: " . $email; } }
public function register() { $this->load->library('form_validation'); if ($this->form_validation->run('admin-registration') == FALSE) { $this->session->set_flashdata('message', ERROR_MESSAGE . ":" . validation_errors()); return FALSE; } $token = md5(uniqid() . microtime() . rand()); $password = generatePassword(); $email = $this->input->post('email'); $insert_data = array('name' => $this->input->post('name'), 'email' => $email, 'password' => md5($password), 'token' => $token, 'status' => 0, 'role_id' => ADMIN, 'created_at' => $today_datetime, 'created_by' => $this->session->userdata('user_data')->id); $result = $this->db->insert($this->table_name, $insert_data); $this->session->set_flashdata('message', ERROR_MESSAGE . ":Registration failed. Something went wrong"); if ($result) { $this->session->set_flashdata('message', "Registered Successfully"); // sending pararmeter for sending email $recipent_data = array(); $recipent_data['password'] = $password; $recipent_data['email'] = $email; $recipent_data['type'] = 'Admin'; $recipent_data['name'] = $this->input->post('name'); //calling function in email_templates_helper // $email_status = register_email($recipent_data); // to admin $recipent_data['token'] = $token; $recipent_data['url'] = '<a href="' . base_url() . 'admin/email_authentication/' . $token . '"> verify here</a>'; // $email_status = admin_registration_verification_email($recipent_data); } return $result; }
/** * @return array|string */ protected function getPassword() { $this->password = $this->option('password'); if (empty($this->password)) { $this->password = generatePassword(); $this->info(sprintf('Using auto generated password: %s', $this->password)); } return $this->password; }
function genPassword() { return generatePassword(8); #********** Set of words **************** $word_arr_one = array("rose", "pink", "blue", "cyan", "gold", "lime", "silk", "slim", "walk", "warm", "zoom", "high", "hell", "posh", "face", "hand", "dose", "cool", "club", "clue", "baby", "body", "auto", "acid"); $word_arr_two = array("aunt", "love", "girl", "time", "door", "disc", "book", "news", "c**k", "bond", "bomb", "joke", "tall", "tank", "drum", "hill", "hand", "cook", "look", "mate", "main", "pack", "page", "palm"); $arr_one_len = sizeof($word_arr_one); $arr_two_len = sizeof($word_arr_two); #********* Randomize on microseconds ******** mt_srand((double) microtime() * 1000000); #********************************************************** # Construct a string by picking up 8 words in random # from first array of words # Add word at start if pick up word is at even position # otherwise add at end of the string #************************************************************ for ($i = 0; $i < 10; $i++) { $pos_one = mt_rand(0, $arr_one_len - 1); if ($pos_one % 2 == 0) { $pwd_one = $word_arr_one[$pos_one] . $pwd_one; } else { $pwd_one .= $word_arr_one[$pos_one]; } } #********************************************************** # Construct a string by picking up 8 words in random # from second array of words # Add word at end if pick up word is at even position # otherwise add at start of the string #************************************************************ for ($i = 0; $i < 10; $i++) { $pos_two = mt_rand(0, $arr_two_len - 1); if ($pos_two % 2 == 0) { $pwd_two .= $word_arr_two[$pos_two]; } else { $pwd_two = $word_arr_two[$pos_two] . $pwd_two; } } #********* pick up a random number between 1 and 9 *********** $rnd_int = mt_rand(2, 9); #****************************************************************************** # Now to generate password # pick up first word(4 letters) from first string(constructed from array one) # + # number you picked up in random # + # pich up first word(4 letters) from second string(constructed from array two) #****************************************************************************** $pwd = substr($pwd_one, 0, 4) . $rnd_int . substr($pwd_two, 0, 4); return $pwd; }
*/ /* Simply gets the proper information to process a login. */ function processDBLogin($userid) { $userid = makeStringSafe($userid); return doQuery("SELECT user_id,password,user_level FROM " . getDBPrefix() . "_users WHERE username = '******'"); } /* Creates a new user and gives them a random password. It then returns that password. */ function newUserNoPassword($stuid, $name, $email, $user_level) { $stuid = makeStringSafe($stuid);
function generatePassword($len = 12) { $password = null; $chars = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $i = 1; // get a new password do { $password .= substr($chars, mt_rand(0, strlen($chars) - 1), 1); } while (strlen($password) < $len); if (isStrong($password) === false) { do { $password = generatePassword(); } while (isStrong($password) === false); } return $password; }
function connexion($user, $mdp, $raw = false) { global $bdd; if ($raw == false) { $mdp = generatePassword($mdp); } $req = $bdd->prepare("SELECT idJoueur FROM JOUEUR WHERE pseudoJoueur=:user AND motdepasseJoueur=:pass"); $req->execute(array('user' => $user, 'pass' => $mdp)); $id = $req->fetchAll()[0][0]; $_SESSION['idJoueur'] = $id; if ($id > 0) { return true; } else { return false; } }
function administratorLogIn($db, $email, $password) { $check = $db->prepare('SELECT * FROM person WHERE email = :email'); $check->execute(array(':email' => $email)); if (($emailExist = $check->fetch()) && verifyPassword($emailExist['hash'], $password)) { $update = $db->prepare('UPDATE person SET hash = :hash, last_connection = :lastConnection WHERE id = :id'); $update->execute(array(':hash' => generatePassword($password), ':lastConnection' => date('Y-m-d H:i:s'), ':id' => $emailExist['id'])); $_SESSION['id'] = $emailExist['id']; $_SESSION['first_name'] = $emailExist['first_name']; $_SESSION['last_name'] = $emailExist['last_name']; $_SESSION['gender'] = $emailExist['gender']; $_SESSION['email'] = $emailExist['email']; $_SESSION['is_administrator'] = $emailExist['is_administrator']; $_SESSION['last_connection'] = $emailExist['last_connection']; } else { header('Location: index.php?msg=errorConnection'); } }
function readFromCSV($path) { $file = fopen($path, 'r'); while (($line = fgetcsv($file)) !== FALSE) { if (!empty($line[0]) && !empty($line[1])) { $data['first_name'] = $line[0]; $data['last_name'] = $line[1]; $data['email'] = $line[2]; // use random password $data['password'] = generatePassword(); // take out the timezone since all dates are in UTC // 2015-06-08 21:22:53 +0000 $temp_date = explode(" ", $line[3]); $stripped_date = $temp_date[0] . " " . $temp_date[1]; $data['created_date'] = $stripped_date; upsertCustomer($data); unset($data); } } }
public function resetPassword($iUser) { $user = $this->getUserByPk($iUser); if ($user) { $sPass = generatePassword(14, 8); $user->setPassword($this->CI->auth->encodePsswd($sPass)); $this->em->persist($user); $this->em->flush(); return $sPass; ob_start(); require_once "application/views/mailMessages/resetpassword.php"; $body = ob_get_clean(); $subject = "Parola contului a fost resetată"; \NeoMail::genericMail($body, $subject, $email); $this->em->persist($user); $this->em->flush(); return true; } else { return false; } }
/** * function to reset a user's password * @param: $email */ function resetPassword($email) { global $datetime,$borrowercentralCuser,$home_domain; $query=0; $query=mysqlquery("select * from vl_users where email='$email'"); if(mysqlnumrows($query)) { //reset the password and mail the user $newPassword=0; $newPassword=generatePassword(); //now reset the password mysqlquery("update vl_users set xp='".borrowercentralcSimpleEncrypt($newPassword)."', password='******' where email='$email'"); //inform the user by email //subject $subject=0; $subject="Password Reset"; //variables $password=0; $password=$newPassword; //the message $message=0; $message=" Your password has been reset. Your new password is: $password To preserve your privacy, we recommend that you login and change your password. Kind regards, System Team"; //mail the user sendPlainEmail($email,$subject,$message); } }
function login() { $this->form_validation->set_rules('username', 'username', 'trim|required', ''); $this->form_validation->set_rules('password', 'password', 'trim|required', ''); $this->form_validation->set_error_delimiters('<div class="remember-me">', '</div>'); if ($this->form_validation->run() == FALSE) { $this->load->view('index'); } else { $this->load->model('model_login'); $hash_passwd = generatePassword($this->input->post('password')); $result = $this->model_login->admin_login($this->input->post('username'), $hash_passwd); if ($result) { foreach ($result as $row) { $this->session->set_userdata(array('logged_in' => TRUE, 'user_id' => $row->user_id, 'user_first_name' => $row->user_first_name, 'user_last_name' => $row->user_last_name, 'user_email' => $row->user_email, 'user_type' => $row->user_type)); } redirect($this->config->item('base_url') . 'dashboard'); } else { $this->session->set_flashdata('message', _erMsg2('<h5 style="color:red">You Have Entered Invalid Credentials</h5>')); redirect($this->config->item('base_url') . 'index'); } } }
function ReadAccountFile() { global $ACCOUNT_FILE; global $users; $users = array(); $fp = fopen($ACCOUNT_FILE, "rt"); if ($fp == false) { exit(-1); } while (!feof($fp)) { $delim = " \t\n\r"; $buf = fgets($fp, 1024); $id = strtok($buf, $delim); if ($id == false) { continue; } $name = strtok($delim); if ($name == false) { continue; } $dept = strtok($delim); if ($dept == false) { continue; } $email = strtok($delim); if ($email == false) { continue; } $pwd = strtok($delim); //if ( $pwd == false) $pwd = generatePassword(13, 4); $users[$id]['name'] = $name; $users[$id]['dept'] = $dept; $users[$id]['email'] = $email; $users[$id]['pwd'] = $pwd; } fclose($fp); // print_r($users); }
function insert() { global $prepare_query_insert; $pass = generatePassword(); $sha_pass = SHA1(strtoupper($_POST['user']) . ':' . strtoupper($pass)); try { $prepare_query_insert->execute(array(':pass' => $sha_pass, ':name' => $_POST['user'])); } catch (Exception $e) { exit("<div align=\"center\"><font color=\"red\">Erreur lors de la requête pour la mise à jour !<br />Message d'erreur : " . $e->getMessage() . "</font></div>"); } $sujet = "Votre nouveau mot de passe"; $corps = "Bonjour,\n,Suite à votre demande de réinitialisation de mot de passe,\nNous vous fournissons votre nouveau mot de passe :\n " . $pass . " \nSi vous n'avez jamais demandé une réinitialisation de mot de passe, veuillez nous contacter au plus vite !\nCordialement,l'équipe du serveur."; global $array_site; $headers = "From: " . $array_site['email']; ini_set('SMTP', $array_site['smtp']); ini_set('smtp_port', $array_site['smtp_port']); if (mail($_POST['email'], $sujet, $corps, $headers)) { return true; } else { exit("<div align=\"center\"><font color=\"red\">Erreur lors de l'envoi de l'email. Veuillez contacter l'administrateur</font></div>"); } }
function check($user, $pass) { try { $db = new SQLite3(':memory:'); $db->query('CREATE TABLE IF NOT EXISTS users (username TEXT, password TEXT)'); $us = array('admin', 'user', 'member', 'bob'); foreach ($us as $u) { $db->query("INSERT INTO users (username, password) SELECT '" . $u . "', '" . generatePassword() . "' WHERE NOT EXISTS (SELECT 1 FROM users WHERE username = '******')"); } if (strlen($user) > 32 || strlen($pass) > 32) { res('Username or password too long!'); } $res = $db->query("SELECT COUNT(*) FROM users WHERE username = '******' AND password = '******'"); if (!$res) { res('SQL Error: ' . $db->lastErrorMsg()); } $row = $res->fetchArray(); return $row[0] != 0; } catch (Exception $e) { res('Error: ' . $e->getMessage()); error_log($e); } }
function antispam(&$object, $params) { global $modx; $fields = array('address', 'captcha', 'emailConfirm', 'emailCheck', 'easyCaptcha', 'email-retype', 'emailRetype', 'email2', 'nickName', 'siteAddress', 'siteUrl', 'url1'); $fieldName = $fields[array_rand($fields)]; $className = 'jot-form-' . generatePassword(); $found = false; switch ($object->event) { case 'onBeforePOSTProcess': foreach ($fields as $val) { if (isset($_POST[$val]) && empty($_POST[$val])) { $found = true; } } if (!$found) { $object->form['error'] = 4; $object->form['confirm'] = 0; return true; } break; case 'onSetFormOutput': $block = ' <div class="' . $className . '"> <input type="text" name="' . $fieldName . '" value="" size="40" /> </div> </form>'; $css = '<style type="text/css">.' . $className . ' {left:0; position:absolute; top:-500px; width:1px; height:1px; overflow:hidden; visibility:hidden;}</style>'; if ($_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest') { $modx->regClientCSS($css); } else { $block .= $css; } $object->config["html"]["form"] = str_replace('</form>', $block, $object->config["html"]["form"]); break; } }
// Author: Paul Lemmons //---------------------------------------------------------------------------- include 'include/RegFunctions.php'; $message = ''; if (isset($_POST['reset'])) { $address = isset($_POST['email']) ? $_POST['email'] : ''; if (!filter_var($address, FILTER_VALIDATE_EMAIL)) { $message = "I am sorry, that does not look like a valid email address."; } else { $result = $db->query("select Userid\n from {$UsersTable}\n where email = '{$address}'") or die("Unable to get user information: " . sqlError()); $row = $result->fetch(PDO::FETCH_ASSOC); $Userid = isset($row['Userid']) ? $row['Userid'] : ''; if ($Userid == '') { $message = "I am sorry, I cannot find that email address in the database."; } else { $password = generatePassword(8); $newPass = password_hash($password, PASSWORD_DEFAULT); $subject = "LTC Password Reset"; $email = "<html>"; $email .= " <head>\n"; $email .= " <title>\n"; $email .= " LTC Password Reset\n"; $email .= " </title>\n"; $email .= " <h1 align=center>\n"; $email .= " LTC Password Reset\n"; $email .= " </h1>\n"; $email .= " </head>\n"; $email .= " <body>\n"; $email .= " <p>\n"; $email .= " So, it appears that you have forgotten your password. No problem. I have reset it for you.<br>\n"; $email .= " I am not so smart, though, so the password I chose for it is probably pretty ugly. You will want to\n<br>";
$wordsPickedAndNumber = addNumber($wordsPicked); $wordsPickedFinal = addCharacter($wordsPickedAndNumber); $passwordString = printPassword($wordsPickedFinal, $passwordString); } else { if ($includeNumber) { generatePassword($numberOfWords, $wordList); $wordsPicked = addNumber($wordsPicked); $passwordString = printPassword($wordsPicked, $passwordString); } else { if ($specialCharacter) { generatePassword($numberOfWords, $wordList); $wordsPicked = addCharacter($wordsPicked); $passwordString = printPassword($wordsPicked, $passwordString); } else { //$wordsPicked = generatePassword($numberOfWords, $wordsPicked, $wordList); generatePassword($numberOfWords, $wordList); $passwordString = printPassword($wordsPicked, $passwordString); } } } } /* * This is a function that generates random words inside an array. * @param: $numberOfWords, $array, $wordList * @return: N/A */ function generatePassword($numberOfWords, $wordList) { global $wordsPicked; // pick random numbers that matches the number user inputs for ($i = 0; $i < $numberOfWords; $i++) {
<?php /** * This file is part of the Froxlor project. * Copyright (c) 2010 the Froxlor Team (see authors). * * For the full copyright and license information, please view the COPYING * file that was distributed with this source code. You can also view the * COPYING file online at http://files.froxlor.org/misc/COPYING.txt * * @copyright (c) the authors * @author Froxlor team <*****@*****.**> (2010-) * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt * @package Formfields * */ return array('customer_add' => array('title' => $lng['admin']['customer_add'], 'image' => 'icons/user_add.png', 'sections' => array('section_a' => array('title' => $lng['admin']['accountdata'], 'image' => 'icons/user_add.png', 'fields' => array('new_loginname' => array('label' => $lng['login']['username'], 'type' => 'text'), 'createstdsubdomain' => array('label' => $lng['admin']['stdsubdomain_add'] . '?', 'type' => 'checkbox', 'values' => array(array('label' => $lng['panel']['yes'], 'value' => '1')), 'value' => array('1')), 'store_defaultindex' => array('label' => $lng['admin']['store_defaultindex'] . '?', 'type' => 'checkbox', 'values' => array(array('label' => $lng['panel']['yes'], 'value' => '1')), 'value' => array('1')), 'new_customer_password' => array('label' => $lng['login']['password'], 'type' => 'password', 'autocomplete' => 'off'), 'new_customer_password_suggestion' => array('label' => $lng['customer']['generated_pwd'], 'type' => 'text', 'visible' => Settings::Get('panel.password_regex') == '', 'value' => generatePassword()), 'sendpassword' => array('label' => $lng['admin']['sendpassword'], 'type' => 'checkbox', 'values' => array(array('label' => $lng['panel']['yes'], 'value' => '1')), 'value' => array('1')), 'def_language' => array('label' => $lng['login']['language'], 'type' => 'select', 'select_var' => $language_options))), 'section_b' => array('title' => $lng['admin']['contactdata'], 'image' => 'icons/user_add.png', 'fields' => array('name' => array('label' => $lng['customer']['name'], 'type' => 'text', 'mandatory_ex' => true), 'firstname' => array('label' => $lng['customer']['firstname'], 'type' => 'text', 'mandatory_ex' => true), 'gender' => array('label' => $lng['gender']['title'], 'type' => 'select', 'select_var' => $gender_options), 'company' => array('label' => $lng['customer']['company'], 'type' => 'text', 'mandatory_ex' => true), 'street' => array('label' => $lng['customer']['street'], 'type' => 'text'), 'zipcode' => array('label' => $lng['customer']['zipcode'], 'type' => 'text'), 'city' => array('label' => $lng['customer']['city'], 'type' => 'text'), 'phone' => array('label' => $lng['customer']['phone'], 'type' => 'text'), 'fax' => array('label' => $lng['customer']['fax'], 'type' => 'text'), 'email' => array('label' => $lng['customer']['email'], 'type' => 'text', 'mandatory' => true), 'customernumber' => array('label' => $lng['customer']['customernumber'], 'type' => 'text'), 'custom_notes' => array('style' => 'align-top', 'label' => $lng['usersettings']['custom_notes']['title'], 'desc' => $lng['usersettings']['custom_notes']['description'], 'type' => 'textarea', 'cols' => 60, 'rows' => 12), 'custom_notes_show' => array('label' => $lng['usersettings']['custom_notes']['show'], 'type' => 'checkbox', 'values' => array(array('label' => $lng['panel']['yes'], 'value' => '1')), 'value' => array()))), 'section_c' => array('title' => $lng['admin']['servicedata'], 'image' => 'icons/user_add.png', 'fields' => array('diskspace' => array('label' => $lng['customer']['diskspace'], 'type' => 'textul', 'value' => 0, 'maxlength' => 6, 'mandatory' => true, 'ul_field' => $diskspace_ul), 'traffic' => array('label' => $lng['customer']['traffic'], 'type' => 'textul', 'value' => 0, 'maxlength' => 4, 'mandatory' => true, 'ul_field' => $traffic_ul), 'subdomains' => array('label' => $lng['customer']['subdomains'], 'type' => 'textul', 'value' => 0, 'maxlength' => 9, 'mandatory' => true, 'ul_field' => $subdomains_ul), 'emails' => array('label' => $lng['customer']['emails'], 'type' => 'textul', 'value' => 0, 'maxlength' => 9, 'mandatory' => true, 'ul_field' => $emails_ul), 'email_accounts' => array('label' => $lng['customer']['accounts'], 'type' => 'textul', 'value' => 0, 'maxlength' => 9, 'mandatory' => true, 'ul_field' => $email_accounts_ul), 'email_forwarders' => array('label' => $lng['customer']['forwarders'], 'type' => 'textul', 'value' => 0, 'maxlength' => 9, 'mandatory' => true, 'ul_field' => $email_forwarders_ul), 'email_quota' => array('label' => $lng['customer']['email_quota'], 'type' => 'textul', 'value' => 0, 'maxlength' => 9, 'visible' => Settings::Get('system.mail_quota_enabled') == '1' ? true : false, 'mandatory' => true, 'ul_field' => $email_quota_ul), 'email_imap' => array('label' => $lng['customer']['email_imap'], 'type' => 'checkbox', 'values' => array(array('label' => $lng['panel']['yes'], 'value' => '1')), 'value' => array('1'), 'mandatory' => true), 'email_pop3' => array('label' => $lng['customer']['email_pop3'], 'type' => 'checkbox', 'values' => array(array('label' => $lng['panel']['yes'], 'value' => '1')), 'value' => array('1'), 'mandatory' => true), 'ftps' => array('label' => $lng['customer']['ftps'], 'type' => 'textul', 'value' => 0, 'maxlength' => 9, 'ul_field' => $ftps_ul), 'tickets' => array('label' => $lng['customer']['tickets'], 'type' => 'textul', 'value' => 0, 'maxlength' => 9, 'visible' => Settings::Get('ticket.enabled') == '1' ? true : false, 'ul_field' => $tickets_ul), 'mysqls' => array('label' => $lng['customer']['mysqls'], 'type' => 'textul', 'value' => 0, 'maxlength' => 9, 'mandatory' => true, 'ul_field' => $mysqls_ul), 'phpenabled' => array('label' => $lng['admin']['phpenabled'] . '?', 'type' => 'checkbox', 'values' => array(array('label' => $lng['panel']['yes'], 'value' => '1')), 'value' => array('1')), 'perlenabled' => array('label' => $lng['admin']['perlenabled'] . '?', 'type' => 'checkbox', 'values' => array(array('label' => $lng['panel']['yes'], 'value' => '1'))), 'dnsenabled' => array('label' => $lng['admin']['dnsenabled'] . '?', 'type' => 'checkbox', 'values' => array(array('label' => $lng['panel']['yes'], 'value' => '1')), 'visible' => Settings::Get('system.dnsenabled') == '1' ? true : false))))));
$pagetitle = "Add a New Contact"; $navtitle = 'Contacts'; $keywords = ''; $description = ''; include "/srv/athenace/lib/shared/common.php"; include "/srv/athenace/lib/intranet/common.php"; include "/srv/athenace/lib/shared/functions_form.php"; $fields = array("fname", "sname", "co_name", "role", "notes", "custid", "suppid"); foreach ($fields as $field) { if (!isset($_POST[$field])) { $_POST[$field] = ''; } } if (isset($_GET['go']) && $_GET['go'] == "y") { $logContent = "\n"; $pw = generatePassword(); // Add to Address table $addsid = db_addAddress($_POST); $logon = generateContactlogon($_POST['fname'], $_POST['sname']); // Insert into DB $contactsNew = new Contacts(); $contactsNew->setFname($_POST['fname']); $contactsNew->setSname($_POST['sname']); $contactsNew->setCo_name($_POST['co_name']); $contactsNew->setRole($_POST['role']); $contactsNew->setCustid($_POST['custid']); $contactsNew->setSuppid($_POST['suppid']); $contactsNew->setAddsid($addsid); $contactsNew->setNotes($_POST['notes']); $contactId = $contactsNew->insertIntoDB(); // Insert into DB
while ($r = mysql_fetch_array($res)) { $content .= '<option value="' . $r['id'] . '">' . $r['nombre'] . '</option>'; } $salida = ' <select name="lista_perfiles" id="lista_perfiles"> <option value="0" selected="selected">SELECCIONE UN PERFIL</option> ' . $content . ' </select> '; break; //GENERAR Y ENVIAR CLAVE DE ACCESO NUEVA //GENERAR Y ENVIAR CLAVE DE ACCESO NUEVA case 'generar-password': $content = ""; //GENERAR CLAVE DE ACCESO ALEATORIA $psswtemp = generatePassword(); $password = crypt($psswtemp, 'crp'); //BUSCAR REGISTRO CON CORREO $_POST['email'] $query = "UPDATE `aRecurso_usuarios` SET `password`='" . $password . "' WHERE `email`='" . $_POST['email'] . "'"; $res = mysql_query($query); echo mysql_error(); //ENVIAR NOTIFICACIÓN Y CONTRASEÑA NUEVA //para el envío en formato HTML $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=utf-8\r\n"; //dirección del remitente $headers .= "From: CICESE-REP <*****@*****.**>\r\n"; $content = "<html> \n\t\t\t\t\t\t<head> \n\t\t\t\t\t\t\t<title>Clave de acceso</title>\n\t\t\t\t\t\t</head> \n\t\t\t\t\t\t<body>\n\t\t\t\t\t\t\t<strong>CICESE-REP</strong>\n\t\t\t\t\t\t\t<p align='justify'>Se ha generado una nueva clave de acceso con base en su solicitud del día.</p>\n\t\t\t\t\t\t\t<p><strong>Clave de acceso: <i>" . $psswtemp . "</i></strong></p> \n\t\t\t\t\t\t\t<p>http://numenor.cicese.mx/repositorio</p>\n\t\t\t\t\t\t\t<p align='justify' style='color:#003399'>AVISO DE CONFIDENCIALIDAD: Este correo electrónico es confidencial y para uso exclusivo de la(s) persona(s) a quien(es) se dirige. Si el lector de esta transmisión electrónica no es el destinatario, se le notifica que cualquier distribución o copia de la misma está estrictamente prohibida. Si ha recibido este correo por error le suplicamos notificar inmediatamente a la persona que lo envió y borrarlo definitivamente de su sistema. Gracias.</p>\n\t\t\t\t\t\t\t<p align='justify' style='color:#003399'>CONFIDENTIALITY NOTICE: This electronic mail transmission is confidential, may be privileged and should be read or retained only by the intended recipient. If the reader of this transmission is not the intended recipient, you are hereby notified that any distribution or copying hereof is strictly prohibited. If you have received this transmission in error, please immediately notify the sender and delete it from your system. Thank you.</p>\n\t\t\t\t\t\t</body> \n\t\t\t\t\t\t</html>"; mail($_POST['email'], "Clave de acceso CICESE-REP", $content, $headers); $salida = 'OK'; break;
public function tempnam_sfx($path, $prefix, $suffix) { do { $fileName = $prefix . "_" . generatePassword(8) . '.' . $suffix; $file = $path . $fileName; $fp = @fopen($file, 'x'); } while (!$fp); fclose($fp); return $fileName; }
<?php /** * This file is part of the Froxlor project. * Copyright (c) 2010 the Froxlor Team (see authors). * * For the full copyright and license information, please view the COPYING * file that was distributed with this source code. You can also view the * COPYING file online at http://files.froxlor.org/misc/COPYING.txt * * @copyright (c) the authors * @author Froxlor team <*****@*****.**> (2010-) * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt * @package Formfields * */ return array('admin_add' => array('title' => $lng['admin']['admin_add'], 'image' => 'icons/user_add.png', 'sections' => array('section_a' => array('title' => $lng['admin']['accountdata'], 'image' => 'icons/user_add.png', 'fields' => array('loginname' => array('label' => $lng['login']['username'], 'type' => 'text', 'mandatory' => true), 'admin_password' => array('label' => $lng['login']['password'], 'type' => 'password', 'mandatory' => true, 'autocomplete' => 'off'), 'admin_password_suggestion' => array('label' => $lng['customer']['generated_pwd'], 'type' => 'text', 'value' => generatePassword()), 'def_language' => array('label' => $lng['login']['language'], 'type' => 'select', 'select_var' => $language_options))), 'section_b' => array('title' => $lng['admin']['contactdata'], 'image' => 'icons/user_add.png', 'fields' => array('name' => array('label' => $lng['customer']['name'], 'type' => 'text', 'mandatory' => true), 'email' => array('label' => $lng['customer']['email'], 'type' => 'text', 'mandatory' => true))), 'section_c' => array('title' => $lng['admin']['servicedata'], 'image' => 'icons/user_add.png', 'fields' => array('ipaddress' => array('label' => $lng['serversettings']['ipaddress']['title'], 'type' => 'select', 'select_var' => $ipaddress), 'change_serversettings' => array('label' => $lng['admin']['change_serversettings'], 'type' => 'checkbox', 'values' => array(array('label' => $lng['panel']['yes'], 'value' => '1')), 'value' => array()), 'customers' => array('label' => $lng['admin']['customers'], 'type' => 'textul', 'value' => 0, 'maxlength' => 9, 'mandatory' => true, 'ul_field' => $customers_ul), 'customers_see_all' => array('label' => $lng['admin']['customers_see_all'], 'type' => 'checkbox', 'values' => array(array('label' => $lng['panel']['yes'], 'value' => '1')), 'value' => array()), 'domains' => array('label' => $lng['admin']['domains'], 'type' => 'textul', 'value' => 0, 'maxlength' => 9, 'mandatory' => true, 'ul_field' => $domains_ul), 'domains_see_all' => array('label' => $lng['admin']['domains_see_all'], 'type' => 'checkbox', 'values' => array(array('label' => $lng['panel']['yes'], 'value' => '1')), 'value' => array()), 'caneditphpsettings' => array('label' => $lng['admin']['caneditphpsettings'], 'type' => 'checkbox', 'values' => array(array('label' => $lng['panel']['yes'], 'value' => '1')), 'value' => array()), 'diskspace' => array('label' => $lng['customer']['diskspace'], 'type' => 'textul', 'value' => 0, 'maxlength' => 6, 'mandatory' => true, 'ul_field' => $diskspace_ul), 'traffic' => array('label' => $lng['customer']['traffic'], 'type' => 'textul', 'value' => 0, 'maxlength' => 4, 'mandatory' => true, 'ul_field' => $traffic_ul), 'subdomains' => array('label' => $lng['customer']['subdomains'], 'type' => 'textul', 'value' => 0, 'maxlength' => 9, 'mandatory' => true, 'ul_field' => $subdomains_ul), 'emails' => array('label' => $lng['customer']['emails'], 'type' => 'textul', 'value' => 0, 'maxlength' => 9, 'mandatory' => true, 'ul_field' => $emails_ul), 'email_accounts' => array('label' => $lng['customer']['accounts'], 'type' => 'textul', 'value' => 0, 'maxlength' => 9, 'mandatory' => true, 'ul_field' => $email_accounts_ul), 'email_forwarders' => array('label' => $lng['customer']['forwarders'], 'type' => 'textul', 'value' => 0, 'maxlength' => 9, 'mandatory' => true, 'ul_field' => $email_forwarders_ul), 'email_quota' => array('label' => $lng['customer']['email_quota'], 'type' => 'textul', 'value' => 0, 'maxlength' => 9, 'visible' => $settings['system']['mail_quota_enabled'] == '1' ? true : false, 'mandatory' => true, 'ul_field' => $email_quota_ul), 'email_autoresponder' => array('label' => $lng['customer']['autoresponder'], 'type' => 'textul', 'value' => 0, 'maxlength' => 9, 'visible' => $settings['autoresponder']['autoresponder_active'] == '1' ? true : false, 'ul_field' => $email_autoresponder_ul), 'ftps' => array('label' => $lng['customer']['ftps'], 'type' => 'textul', 'value' => 0, 'maxlength' => 9, 'ul_field' => $ftps_ul), 'tickets' => array('label' => $lng['customer']['tickets'], 'type' => 'textul', 'value' => 0, 'maxlength' => 9, 'visible' => $settings['ticket']['enabled'] == '1' ? true : false, 'ul_field' => $tickets_ul), 'mysqls' => array('label' => $lng['customer']['mysqls'], 'type' => 'textul', 'value' => 0, 'maxlength' => 9, 'mandatory' => true, 'ul_field' => $mysqls_ul), 'can_manage_aps_packages' => array('label' => $lng['aps']['canmanagepackages'], 'type' => 'checkbox', 'values' => array(array('label' => $lng['panel']['yes'], 'value' => '1')), 'value' => array(), 'visible' => $settings['aps']['aps_active'] == '1' ? true : false), 'number_of_aps_packages' => array('label' => $lng['aps']['numberofapspackages'], 'type' => 'textul', 'value' => 0, 'maxlength' => 9, 'visible' => $settings['aps']['aps_active'] == '1' ? true : false, 'ul_field' => $number_of_aps_packages_ul))))));
// processing npwpd_old - end // processing id_old - start $inlineAddOption = true; if ($inlineAddOption) { $control_id_old->afterSuccessfulSave(); } // processing id_old - end $afterAdd_id = ''; if ($eventObj->exists("AfterAdd") && $inlineadd != ADD_MASTER) { $eventObj->AfterAdd($avalues, $keys, (bool) $inlineadd, $pageObject); } else { if ($eventObj->exists("AfterAdd") && $inlineadd == ADD_MASTER) { if ($onFly) { $eventObj->AfterAdd($avalues, $keys, (bool) $inlineadd, $pageObject); } else { $afterAdd_id = generatePassword(20); $_SESSION['after_add_data'][$afterAdd_id] = array('avalues' => $avalues, 'keys' => $keys, 'inlineadd' => (bool) $inlineadd, 'time' => time()); } } } if ($inlineadd == ADD_SIMPLE || $inlineadd == ADD_MASTER) { $permis = array(); $keylink = ""; $k = 0; foreach ($keys as $idx => $val) { if ($k != 0) { $keylink .= "&"; } $keylink .= "editid" . ++$k . "=" . htmlspecialchars(rawurlencode(@$val)); } $permis = $pageObject->getPermissions();
function createInstructor() { $flag = true; if (empty($_POST["lastname"])) { global $lastnameErr; $lastnameErr = "Last name is required"; $flag = false; } else { $lastname = test_input($_POST["lastname"]); } if (empty($_POST["firstname"])) { global $firstnameErr; $firstnameErr = "First name is required"; $flag = false; } else { $firstname = test_input($_POST["firstname"]); } if (empty($_POST["email"])) { global $emailErr; $emailErr = "Email is required"; $flag = false; } else { $email = test_input($_POST["email"]); } $position = $_POST["position"]; if ($flag == true) { $firstname = mysql_real_escape_string($firstname); $lastname = mysql_real_escape_string($lastname); $email = mysql_real_escape_string($email); $position = mysql_real_escape_string($position); $pw = generatePassword($firstname . " " . $lastname); $query = "SELECT * FROM Instructor WHERE firstname='{$firstname}' AND lastname='{$lastname}'"; //change tablename $result = mysql_query($query); if ($result != null && mysql_num_rows($result) >= 1) { echo "<p class=notice>Unable to create. Instructor already exists. If you want to change information please first delete from the list below.</p>"; } else { $query = "INSERT INTO Instructor (firstname, lastname, email, position,pass) VALUES ( '{$firstname}', '{$lastname}', '{$email}', '{$position}', '{$pw}')"; //change tablename $result = mysql_query($query); if (!$result) { die("Cannot create instructor: " . mysql_error()); } else { echo "<p class=notice>New instructor " . $firstname . " " . $lastname . " is created.</p>"; } } } }