本文整理汇总了PHP中G::generate_password方法的典型用法代码示例。如果您正苦于以下问题:PHP G::generate_password方法的具体用法?PHP G::generate_password怎么用?PHP G::generate_password使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类G
的用法示例。
在下文中一共展示了G::generate_password方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create_site
/**
* create_site
*
* @param array $config
* @param boolean $confirmed
* @return void
*/
public function create_site($config = array(), $confirmed = false)
{
$this->options = G::array_concat(array('isset' => false, 'password' => G::generate_password(12), 'path_data' => @PATH_DATA, 'path_compiled' => @PATH_C, 'name' => $config['name'], 'database' => array(), 'admin' => array('username' => 'admin', 'password' => 'admin'), 'advanced' => array('ao_db_wf' => 'wf_' . $config['name'], 'ao_db_rb' => 'rb_' . $config['name'], 'ao_db_rp' => 'rp_' . $config['name'], 'ao_db_drop' => false)), $config);
$a = @explode(SYSTEM_HASH, G::decrypt(HASH_INSTALLATION, SYSTEM_HASH));
$this->options['database'] = G::array_concat(array('username' => @$a[1], 'password' => @$a[2], 'hostname' => @$a[0]), $this->options['database']);
return $confirmed === true ? $this->make_site() : $this->create_site_test();
}
示例2: testGenerate_password
/**
* @covers G::generate_password
* @todo Implement testGenerate_password().
*/
public function testGenerate_password()
{
// $length = ''
$responsePass = G::generate_password();
$this->assertEquals(strlen($responsePass), 8);
// $length = '32'
$responsePass = G::generate_password(10);
$this->assertEquals(strlen($responsePass), 10);
}
示例3: createMSSQLWorkspace
//.........这里部分代码省略.........
$this->link = @mssql_connect( $db_host, $db_username, $db_password );
$this->installLog( G::LoadTranslation('ID_CONNECT_TO_SERVER', SYS_LANG, Array( $db_hostname, $db_port, $db_username )) );
$this->mssqlQuery( 'USE [master]' );
// DROP databases wf_workflow, rb_workflow and rp_workflow
if ($deleteDB) {
$q = sprintf( "IF EXISTS (SELECT name FROM sys.databases WHERE name='%s' ) DROP DATABASE %s", $wf, $wf );
$this->mssqlQuery( $q );
}
// CREATE databases wf_workflow, rb_workflow and rp_workflow
$q = sprintf( "IF NOT EXISTS (SELECT * FROM sys.databases WHERE name='%s' ) CREATE DATABASE %s", $wf, $wf );
$this->mssqlQuery( $q );
//CREATE users and GRANT Privileges
$wfPass = G::generate_password( 12 );
$this->setGrantPrivilegesMSSQL( $wf, $wfPass, $wf );
//Generate the db.php file and folders
$path_site = $pathShared . "/sites/" . $workspace . "/";
$db_file = $path_site . "db.php";
mkdir( $path_site, 0777, true );
@mkdir( $path_site . "files/", 0777, true );
@mkdir( $path_site . "mailTemplates/", 0777, true );
@mkdir( $path_site . "public/", 0777, true );
@mkdir( $path_site . "reports/", 0777, true );
@mkdir( $path_site . "xmlForms", 0777, true );
$dbText = "<?php\n";
$dbText .= sprintf( "// Processmaker configuration\n" );
$dbText .= sprintf( " define ('DB_ADAPTER', '%s' );\n", 'mssql' );
$dbText .= sprintf( " define ('DB_HOST', '%s' );\n", $db_host );
示例4: RbacUsers
global $RBAC;
require_once PATH_RBAC . "model/RbacUsers.php";
G::LoadClass('pmFunctions');
require_once 'classes/model/Users.php';
G::LoadClass("system");
$rbacUser = new RbacUsers();
$user = new Users();
$userData = $rbacUser->getByUsername($data['USR_USERNAME']);
if ($userData['USR_EMAIL'] != '' && $userData['USR_EMAIL'] === $data['USR_EMAIL']) {
$aSetup = getEmailConfiguration();
if (count($aSetup) == 0 || !isset($aSetup['MESS_ENGINE'])) {
G::SendTemporalMessage('ID_EMAIL_ENGINE_IS_NOT_ENABLED', "warning");
G::header('location: forgotPassword');
die;
}
$newPass = G::generate_password();
$aData['USR_UID'] = $userData['USR_UID'];
$aData['USR_PASSWORD'] = md5($newPass);
/* **Save after sending the mail
$rbacUser->update($aData);
$user->update($aData);
*/
$sFrom = ($aSetup['MESS_ACCOUNT'] != '' ? $aSetup['MESS_ACCOUNT'] . ' ' : '') . '<' . $aSetup['MESS_ACCOUNT'] . '>';
$sSubject = G::LoadTranslation('ID_RESET_PASSWORD') . ' - ProcessMaker';
$msg = '<h3>ProcessMaker Forgot password Service</h3>';
$msg .= '<p>' . G::LoadTranslation('ID_YOUR_USERMANE_IS') . ' : <strong>' . $userData['USR_USERNAME'] . '</strong></p>';
$msg .= '<p>' . G::LoadTranslation('ID_YOUR_PASSWORD_IS') . ' : <strong>' . $newPass . '</strong></p>';
switch ($aSetup['MESS_ENGINE']) {
case 'MAIL':
$engine = G::LoadTranslation('ID_MESS_ENGINE_TYPE_1');
break;
示例5: forgotPassword
public function forgotPassword($httpData)
{
$this->setResponseType('json');
global $RBAC;
require_once PATH_RBAC . "model/RbacUsers.php";
require_once 'classes/model/Users.php';
G::LoadClass("system");
$rbacUser = new RbacUsers();
$user = new Users();
try {
$userData = $rbacUser->getByUsername($httpData->username);
if (!$userData) {
$msg = G::LoadTranslation('ID_USER') . ' <b>' . $httpData->username . '</b> ' . G::LoadTranslation('ID_IS_NOT_REGISTERED');
throw new Exception($msg);
}
if (trim($userData['USR_EMAIL']) != trim($httpData->email)) {
$msg = G::LoadTranslation('ID_EMAIL_DOES_NOT_MATCH_FOR_USER') . ' <b>' . $httpData->username . '</b>';
throw new Exception($msg);
}
$newPass = G::generate_password();
$aData['USR_UID'] = $userData['USR_UID'];
$aData['USR_PASSWORD'] = md5($newPass);
$rbacUser->update($aData);
$user->update($aData);
$subject = G::loadTranslation('ID_PROCESSMAKER_FORGOT_PASSWORD_SERVICE');
$template = new TemplatePower(PATH_TPL . 'main/forgotPassword.tpl');
$template->prepare();
$template->assign('server', $_SERVER['SERVER_NAME']);
$template->assign('serviceMsg', G::loadTranslation('ID_PROCESSMAKER_FORGOT_PASSWORD_SERVICE'));
$template->assign('content', G::loadTranslation('ID_PASSWORD_CHANGED_SUCCESSFULLY'));
$template->assign('passwd', $newPass);
$template->assign('poweredBy', G::loadTranslation('ID_PROCESSMAKER_SLOGAN1'));
$template->assign('versionLabel', G::loadTranslation('ID_VERSION'));
$template->assign('version', System::getVersion());
$template->assign('visit', G::loadTranslation('ID_VISIT'));
$template->assign('footer', '');
$body = $template->getOutputContent();
G::sendMail('', 'ProcessMaker Service', $httpData->email, $subject, $body);
$result->success = true;
$result->message = G::LoadTranslation('ID_NEW_PASSWORD_SENT');
} catch (Exception $e) {
$result->success = false;
$result->message = $e->getMessage();
}
return $result;
}
示例6: createMSSQLWorkspace
public function createMSSQLWorkspace()
{
ini_set('max_execution_time', '0');
$info->result = false;
$info->message = '';
$db_hostname = trim($_REQUEST['db_hostname']);
$db_port = trim($_REQUEST['db_port']);
$db_username = trim($_REQUEST['db_username']);
$db_password = trim($_REQUEST['db_password']);
$wf = trim($_REQUEST['wfDatabase']);
$rb = trim($_REQUEST['rbDatabase']);
$rp = trim($_REQUEST['rpDatabase']);
$workspace = trim($_REQUEST['workspace']);
$pathConfig = trim($_REQUEST['pathConfig']);
$pathLanguages = trim($_REQUEST['pathLanguages']);
$pathPlugins = trim($_REQUEST['pathPlugins']);
$pathShared = trim($_REQUEST['pathShared']);
$pathXmlforms = trim($_REQUEST['pathXmlforms']);
$adminPassword = trim($_REQUEST['adminPassword']);
$adminUsername = trim($_REQUEST['adminUsername']);
$deleteDB = $_REQUEST['deleteDB'] == 'true';
if (substr($pathShared, -1) != '/') {
$pathShared .= '/';
}
$this->installLog('-------------------------------------------');
$this->installLog(sprintf("Creating workspace '%s' ", $workspace));
try {
$db_host = $db_port != '' && $db_port != 1433 ? $db_hostname . ':' . $db_port : $db_hostname;
$this->link = @mssql_connect($db_host, $db_username, $db_password);
$this->installLog(sprintf("Connected to server %s:%d using user: '%s' ", $db_hostname, $db_port, $db_username));
$this->mssqlQuery('USE [master]');
// DROP databases wf_workflow, rb_workflow and rp_workflow
if ($deleteDB) {
$q = sprintf("IF EXISTS (SELECT name FROM sys.databases WHERE name='%s' ) DROP DATABASE %s", $wf, $wf);
$this->mssqlQuery($q);
$q = sprintf("IF EXISTS (SELECT name FROM sys.databases WHERE name='%s' ) DROP DATABASE %s", $rb, $rb);
$this->mssqlQuery($q);
$q = sprintf("IF EXISTS (SELECT name FROM sys.databases WHERE name='%s' ) DROP DATABASE %s", $rp, $rp);
$this->mssqlQuery($q);
}
// CREATE databases wf_workflow, rb_workflow and rp_workflow
$q = sprintf("IF NOT EXISTS (SELECT * FROM sys.databases WHERE name='%s' ) CREATE DATABASE %s", $wf, $wf);
$this->mssqlQuery($q);
$q = sprintf("IF NOT EXISTS (SELECT * FROM sys.databases WHERE name='%s' ) CREATE DATABASE %s", $rb, $rb);
$this->mssqlQuery($q);
$q = sprintf("IF NOT EXISTS (SELECT * FROM sys.databases WHERE name='%s' ) CREATE DATABASE %s", $rp, $rp);
$this->mssqlQuery($q);
//CREATE users and GRANT Privileges
$wfPass = G::generate_password(12);
$rbPass = G::generate_password(12);
$rpPass = G::generate_password(12);
$this->setGrantPrivilegesMSSQL($wf, $wfPass, $wf);
$this->setGrantPrivilegesMSSQL($rb, $rbPass, $rb);
$this->setGrantPrivilegesMSSQL($rp, $rpPass, $rp);
//Generate the db.php file and folders
$path_site = $pathShared . "/sites/" . $workspace . "/";
$db_file = $path_site . "db.php";
mkdir($path_site, 0777, true);
@mkdir($path_site . "files/", 0777, true);
@mkdir($path_site . "mailTemplates/", 0777, true);
@mkdir($path_site . "public/", 0777, true);
@mkdir($path_site . "reports/", 0777, true);
@mkdir($path_site . "xmlForms", 0777, true);
$dbText = "<?php\n";
$dbText .= sprintf("// Processmaker configuration\n");
$dbText .= sprintf(" define ('DB_ADAPTER', '%s' );\n", 'mssql');
$dbText .= sprintf(" define ('DB_HOST', '%s' );\n", $db_host);
$dbText .= sprintf(" define ('DB_NAME', '%s' );\n", $wf);
$dbText .= sprintf(" define ('DB_USER', '%s' );\n", $wf);
$dbText .= sprintf(" define ('DB_PASS', '%s' );\n", $wfPass);
$dbText .= sprintf(" define ('DB_RBAC_HOST', '%s' );\n", $db_host);
$dbText .= sprintf(" define ('DB_RBAC_NAME', '%s' );\n", $rb);
$dbText .= sprintf(" define ('DB_RBAC_USER', '%s' );\n", $rb);
$dbText .= sprintf(" define ('DB_RBAC_PASS', '%s' );\n", $rbPass);
$dbText .= sprintf(" define ('DB_REPORT_HOST', '%s' );\n", $db_host);
$dbText .= sprintf(" define ('DB_REPORT_NAME', '%s' );\n", $rp);
$dbText .= sprintf(" define ('DB_REPORT_USER', '%s' );\n", $rp);
$dbText .= sprintf(" define ('DB_REPORT_PASS', '%s' );\n", $rpPass);
$this->installLog("Creating: " . $db_file);
file_put_contents($db_file, $dbText);
// Generate the databases.php file
$databases_file = $path_site . 'databases.php';
$dbData = sprintf("\$dbAdapter = '%s';\n", 'mssql');
$dbData .= sprintf("\$dbHost = '%s';\n", $db_host);
$dbData .= sprintf("\$dbName = '%s';\n", $wf);
$dbData .= sprintf("\$dbUser = '%s';\n", $wf);
$dbData .= sprintf("\$dbPass = '%s';\n", $wfPass);
$dbData .= sprintf("\$dbRbacHost = '%s';\n", $db_host);
$dbData .= sprintf("\$dbRbacName = '%s';\n", $rb);
$dbData .= sprintf("\$dbRbacUser = '%s';\n", $rb);
$dbData .= sprintf("\$dbRbacPass = '%s';\n", $rbPass);
$dbData .= sprintf("\$dbReportHost = '%s';\n", $db_host);
$dbData .= sprintf("\$dbReportName = '%s';\n", $rp);
$dbData .= sprintf("\$dbReportUser = '%s';\n", $rp);
$dbData .= sprintf("\$dbReportPass = '%s';\n", $rpPass);
$databasesText = str_replace('{dbData}', $dbData, @file_get_contents(PATH_HOME . 'engine/templates/installer/databases.tpl'));
$this->installLog('Creating: ' . $databases_file);
file_put_contents($databases_file, $databasesText);
//execute scripts to create and populates databases
$query = sprintf("USE %s;", $rb);
//.........这里部分代码省略.........