本文整理汇总了PHP中Shineisp_Commons_Utilities::GenerateRandomPassword方法的典型用法代码示例。如果您正苦于以下问题:PHP Shineisp_Commons_Utilities::GenerateRandomPassword方法的具体用法?PHP Shineisp_Commons_Utilities::GenerateRandomPassword怎么用?PHP Shineisp_Commons_Utilities::GenerateRandomPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shineisp_Commons_Utilities
的用法示例。
在下文中一共展示了Shineisp_Commons_Utilities::GenerateRandomPassword方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateResetPasswordKey
/**
* generateResetPasswordKey
* generate a new key needed for password reset
* @param $customerId
* @return $key
*/
public static function generateResetPasswordKey($customerid)
{
$resetKey = Shineisp_Commons_Utilities::GenerateRandomPassword(24);
$q = Doctrine_Query::create()->update('Customers')->set('resetpwd_key', '?', $resetKey)->set('resetpwd_expire', '?', date('Y-m-d H:i:s', time() + 2 * 3600))->where('customer_id = ?', intval($customerid))->andWhere("isp_id = ?", Isp::getCurrentId());
if ($q->execute()) {
return $resetKey;
}
}
示例2: resetpwdAction
public function resetpwdAction()
{
$request = $this->getRequest();
$resetKey = $request->getParam('id');
$registry = Shineisp_Registry::getInstance();
$translator = $registry->Zend_Translate;
$customer = Customers::getCustomerByResetKey($resetKey);
if ($customer) {
$newPwd = Shineisp_Commons_Utilities::GenerateRandomPassword();
try {
// Update the record
Customers::setCustomerPassword($customer[0]['customer_id'], $newPwd);
// Force expire of reset link
Customers::deleteResetPasswordKey($customer[0]['customer_id']);
} catch (Exception $e) {
echo $e->getMessage();
die;
}
$customer[0]['password'] = $newPwd;
// Getting the email template
Shineisp_Commons_Utilities::sendEmailTemplate($customer[0]['email'], 'password_new', array('fullname' => $customer[0]['lastname'], 'email' => $customer[0]['email'], ':shineisp:' => $customer, 'password' => $newPwd), null, null, null, null, $customer[0]['language_id']);
$this->view->mextype = "success";
$this->view->mex = $translator->translate('Email sent');
} else {
$this->view->mextype = "alert";
$this->view->mex = $translator->translate('An error occurred while setting your password. Please try again.');
}
return $this->_helper->viewRenderer('password');
}
示例3: create_ftp
/**
* Create a new ftp account
*
* Executes the creation of new ftp account in the IspConfig control panel
* Note in order to not fail this command, it must meet the following requirements:
*
* - The customer must be registered in the db.
* - The Web domain must be registered in IspConfig
*
* @param array $task Must be a valid task
* @param integer $websiteID Must be a valid websiteID
* @return mixed True, or throw an Exception if failed.
* @access public
*/
public function create_ftp(array $task, $websiteID)
{
if (!is_numeric($websiteID)) {
throw new Exception(__METHOD__ . ": No website ID found.", "3550");
}
$server = self::getServer($task['orderitem_id'], 'web');
// Get the server id
if (!empty($server['server_id']) && is_numeric($server['server_id'])) {
// Connection to the SOAP system
$client = $this->connect($server['server_id']);
$clientId = self::get_client_id($task, $server['server_id']);
// Get the remote server ID set in the servers profile in ShineISP
$customAttribute = CustomAttributes::getAttribute($server['server_id'], "remote_server_id");
// Get the remote server id set in ShineISP
if (is_numeric($customAttribute['value'])) {
$ServerId = $customAttribute['value'];
// Get the Json encoded parameters in the task
$parameters = json_decode($task['parameters'], true);
if (empty($parameters)) {
throw new Exception("No parameters found in the service", 3501);
}
// Get all the customer information
$customer = Customers::getAllInfo($task['customer_id']);
$id = rand(1, 100);
// Create the username string for instance from John Doe to jdoe
$username = strtolower(substr($customer['firstname'], 0, 1) . preg_replace("#[^a-zA-Z0-9]*#", "", $customer['lastname']));
$username .= "_ftp{$id}";
// Create a random password string
$password = Shineisp_Commons_Utilities::GenerateRandomPassword();
$params = array('server_id' => 1, 'parent_domain_id' => $websiteID, 'username' => $username, 'password' => $password, 'quota_size' => $parameters['webspace'], 'active' => 'y', 'uid' => 'web' . $websiteID, 'gid' => 'client' . $clientId, 'dir' => '/var/www/clients/client' . $clientId . '/web' . $websiteID, 'quota_files' => -1, 'ul_ratio' => -1, 'dl_ratio' => 200, 'ul_bandwidth' => -1, 'dl_bandwidth' => 100);
try {
$ftpUserID = $client->sites_ftp_user_add($this->getSession(), $clientId, $params);
} catch (SoapFault $e) {
throw new Exception("There was a problem with FTP account creation: " . $e->getMessage(), "3506");
}
// Save the setup in the service setup field
OrdersItems::set_setup($task['orderitem_id'], array('host' => $server['ip'], 'username' => $username, 'password' => $password), "ftp");
// Create the log message
Shineisp_Commons_Utilities::logs("ID: " . $task['action_id'] . " - " . __METHOD__ . " - Parameters: " . json_encode($params), "ispconfig.log");
} else {
throw new Exception("No remote web server id set in the ShineISP server profile.", "3502");
}
} else {
throw new Exception("Web Server has not been found in IspConfig server settings.", "3501");
}
// Logout from the IspConfig Remote System
$client->logout($this->getSession());
return $ftpUserID;
}