本文整理汇总了PHP中Tools::passwdGen方法的典型用法代码示例。如果您正苦于以下问题:PHP Tools::passwdGen方法的具体用法?PHP Tools::passwdGen怎么用?PHP Tools::passwdGen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tools
的用法示例。
在下文中一共展示了Tools::passwdGen方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: registerDiscount
public function registerDiscount($id_customer, $register = false, $id_currency = 0)
{
$configurations = Configuration::getMultiple(array('REFERRAL_DISCOUNT_TYPE', 'REFERRAL_PERCENTAGE', 'REFERRAL_DISCOUNT_VALUE_' . (int) $id_currency));
$cartRule = new CartRule();
if ($configurations['REFERRAL_DISCOUNT_TYPE'] == Discount::PERCENT) {
$cartRule->reduction_percent = (double) $configurations['REFERRAL_PERCENTAGE'];
} elseif ($configurations['REFERRAL_DISCOUNT_TYPE'] == Discount::AMOUNT and isset($configurations['REFERRAL_DISCOUNT_VALUE_' . (int) $id_currency])) {
$cartRule->reduction_amount = (double) $configurations['REFERRAL_DISCOUNT_VALUE_' . (int) $id_currency];
}
$cartRule->quantity = 1;
$cartRule->quantity_per_user = 1;
$cartRule->date_from = date('Y-m-d H:i:s', time());
$cartRule->date_to = date('Y-m-d H:i:s', time() + 31536000);
// + 1 year
$cartRule->code = $this->getDiscountPrefix() . Tools::passwdGen(6);
$cartRule->name = Configuration::getInt('REFERRAL_DISCOUNT_DESCRIPTION');
$cartRule->id_customer = (int) $id_customer;
$cartRule->id_currency = (int) $id_currency;
if ($cartRule->add()) {
if ($register != false) {
if ($register == 'sponsor') {
$this->id_cart_rule_sponsor = (int) $cartRule->id;
} elseif ($register == 'sponsored') {
$this->id_cart_rule = (int) $cartRule->id;
}
return $this->save();
}
return true;
}
return false;
}
示例2: __construct
public function __construct()
{
global $cookie;
$this->name = 'ebay';
$this->tab = 'market_place';
$this->version = '1.3.1';
$this->author = 'PrestaShop';
parent::__construct();
$this->displayName = $this->l('eBay');
$this->description = $this->l('Open your shop on the eBay market place !');
$this->id_lang = Language::getIdByIso('fr');
// Check the country and ask the bypass if not 'fr'
if (strtolower(Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'))) != 'fr' && !isset($cookie->ebay_country_default_fr)) {
$this->warning = $this->l('eBay module currently works only for eBay.fr');
return false;
}
// Checking Extension
if (!extension_loaded('curl') || !ini_get('allow_url_fopen')) {
if (!extension_loaded('curl') && !ini_get('allow_url_fopen')) {
$this->warning = $this->l('You must enable cURL extension and allow_url_fopen option on your server if you want to use this module.');
} elseif (!extension_loaded('curl')) {
$this->warning = $this->l('You must enable cURL extension on your server if you want to use this module.');
} elseif (!ini_get('allow_url_fopen')) {
$this->warning = $this->l('You must enable allow_url_fopen option on your server if you want to use this module.');
}
return false;
}
// Checking compatibility with older PrestaShop and fixing it
if (!Configuration::get('PS_SHOP_DOMAIN')) {
Configuration::updateValue('PS_SHOP_DOMAIN', $_SERVER['HTTP_HOST']);
}
// Generate eBay Security Token if not exists
if (!Configuration::get('EBAY_SECURITY_TOKEN')) {
Configuration::updateValue('EBAY_SECURITY_TOKEN', Tools::passwdGen(30));
}
/* For 1.4.3 and less compatibility */
$updateConfig = array('PS_OS_CHEQUE', 'PS_OS_PAYMENT', 'PS_OS_PREPARATION', 'PS_OS_SHIPPING', 'PS_OS_CANCELED', 'PS_OS_REFUND', 'PS_OS_ERROR', 'PS_OS_OUTOFSTOCK', 'PS_OS_BANKWIRE', 'PS_OS_PAYPAL', 'PS_OS_WS_PAYMENT');
if (!Configuration::get('PS_OS_PAYMENT')) {
foreach ($updateConfig as $u) {
if (!Configuration::get($u) && defined('_' . $u . '_')) {
Configuration::updateValue($u, constant('_' . $u . '_'));
}
}
}
// Check if installed
if (self::isInstalled($this->name)) {
// Upgrade eBay module
if (Configuration::get('EBAY_VERSION') != $this->version) {
$this->upgrade();
}
// Generate warnings
if (!Configuration::get('EBAY_API_TOKEN')) {
$this->warning = $this->l('You must register your module on eBay.');
}
// Loading Shipping Method
$this->loadShippingMethod();
// Warning uninstall
$this->confirmUninstall = $this->l('Are you sure you want uninstall this module ? All your configuration will be lost.');
}
}
示例3: install
/**
* Installation du module.
*/
public function install()
{
if (!parent::install() || !$this->registerHook('displayHeader') || !$this->registerHook('actionValidateOrder') || !$this->registerHook('actionObjectOrderHistoryAddAfter') || !$this->registerHook('actionObjectOrderUpdateAfter') || !$this->registerHook('displayAdminOrder') || !$this->installSQL() || !$this->installExternalOrderState()) {
return false;
}
Configuration::updateValue('SHIPTOMYID_CRON_TOKEN', Tools::passwdGen(16));
Configuration::updateValue('SHIPTOMYID_ENABLE', 0);
Configuration::updateValue('SHIPTOMYID_BASE64_MODE', 0);
Configuration::updateValue('SHIPTOMYID_USERNAME', '');
Configuration::updateValue('SHIPTOMYID_PASSWORD', '');
Configuration::updateValue('SHIPTOMYID_WEBSERVICE_URL', Configuration::get('PS_SSL_ENABLED') ? 'https://hotfix-app.ship2myid.com/ship2myid/rest/' : 'http://hotfix-app.ship2myid.com/ship2myid/rest/');
Configuration::updateValue('SHIPTOMYID_TERMS_URL', 'http://www.ship2myid.com/terms-of-use');
Configuration::updateValue('SHIPTOMYID_PRIVACY_URL', 'http://www.ship2myid.com/privacy');
Configuration::updateValue('SHIPTOMYID_VIDEO_LINK', 'http://www.youtube.com/watch?v=_4yvWDuyCis');
Configuration::updateValue('SHIPTOMYID_DEFAULT_ADDR_ADDRESS', 'The shipping address is protected by Ship2MyID.');
Configuration::updateValue('SHIPTOMYID_DEFAULT_ADDR_ADDRESS2', 'X');
Configuration::updateValue('SHIPTOMYID_DEFAULT_ADDR_CITY', 'XX');
Configuration::updateValue('SHIPTOMYID_DEFAULT_ADDR_POSTCODE', 'XXX');
Configuration::updateValue('SHIPTOMYID_DEFAULT_ADDR_PHONE', 'XXXX');
Configuration::updateValue('SHIPTOMYID_DEFAULT_ADDR_ALIAS', 'Ship2MyId');
Configuration::updateValue('SHIPTOMYID_DEFAULT_ADDR_COUNTRY', Configuration::get('PS_COUNTRY_DEFAULT'));
Configuration::updateValue('SHIPTOMYID_DEFAULT_ADDR_STATE', 0);
Configuration::updateValue('SHIPTOMYID_POPUP_URL', Configuration::get('PS_SSL_ENABLED') ? 'https://hotfix-app.ship2myid.com/ship2myid/shopping_cart_popup/index.jsp?plateform=prestashop' : 'http://hotfix-app.ship2myid.com/ship2myid/shopping_cart_popup/index.jsp?plateform=prestashop');
Configuration::updateValue('SHIPTOMYID_POPUP_WIDTH', '634');
Configuration::updateValue('SHIPTOMYID_POPUP_HEIGHT', '774');
Configuration::updateValue('SHIPTOMYID_CANCEL_ORDER_STATE', Configuration::get('PS_OS_CANCELED'));
return true;
}
示例4: registerDiscount
public function registerDiscount($id_customer, $amount, $day, $type, $name)
{
$languages = Language::getLanguages(false);
$cartRule = new CartRule();
if ($type == 'percent') {
$cartRule->reduction_percent = $amount;
} else {
$cartRule->reduction_amount = $amount;
}
$cartRule->quantity = 1;
$cartRule->quantity_per_user = 1;
$cartRule->date_from = date('Y-m-d H:i:s', time());
$cartRule->date_to = date('Y-m-d H:i:s', time() + 86000 * $day);
//$cartRule->minimum_amount = ''; // Utile ?
$cartRule->minimum_amount_tax = true;
$cartRule->code = $name . '_' . strtoupper(Tools::passwdGen(6));
//$cartRule->code = $name;
// QUESTION ?
// It does not work if I do not use languages but it works with the referalprogam module (Prestashop Module)
foreach ($languages as $lang) {
$cartRule->name[$lang['id_lang']] = $name . ' Customer ID :' . $id_customer;
}
$cartRule->id_customer = (int) $id_customer;
$cartRule->reduction_tax = true;
$cartRule->highlight = 1;
if ($cartRule->add()) {
return $cartRule;
}
return false;
}
示例5: install
public function install()
{
if (!parent::install() || !Configuration::updateValue('PS_NEWSLETTER_RAND', rand() . rand()) || !$this->registerHook(array('displayFooterBefore', 'actionCustomerAccountAdd', 'additionalCustomerFormFields'))) {
return false;
}
Configuration::updateValue('NW_SALT', Tools::passwdGen(16));
$conditions = array();
$languages = Language::getLanguages(false);
foreach ($languages as $lang) {
$conditions[(int) $lang['id_lang']] = $this->getConditionFixtures($lang);
}
Configuration::updateValue('NW_CONDITIONS', $conditions, true);
return Db::getInstance()->execute('
CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'emailsubscription` (
`id` int(6) NOT NULL AUTO_INCREMENT,
`id_shop` INTEGER UNSIGNED NOT NULL DEFAULT \'1\',
`id_shop_group` INTEGER UNSIGNED NOT NULL DEFAULT \'1\',
`email` varchar(255) NOT NULL,
`newsletter_date_add` DATETIME NULL,
`ip_registration_newsletter` varchar(15) NOT NULL,
`http_referer` VARCHAR(255) NULL,
`active` TINYINT(1) NOT NULL DEFAULT \'0\',
PRIMARY KEY(`id`)
) ENGINE=' . _MYSQL_ENGINE_ . ' default CHARSET=utf8');
}
示例6: generateSettingsFile
/**
* Generate settings file
*/
public function generateSettingsFile($database_server, $database_login, $database_password, $database_name, $database_prefix, $database_engine)
{
// Check permissions for settings file
if (file_exists(_PS_ROOT_DIR_ . '/' . self::SETTINGS_FILE) && !is_writable(_PS_ROOT_DIR_ . '/' . self::SETTINGS_FILE)) {
$this->setError($this->language->l('%s file is not writable (check permissions)', self::SETTINGS_FILE));
return false;
} elseif (!file_exists(_PS_ROOT_DIR_ . '/' . self::SETTINGS_FILE) && !is_writable(_PS_ROOT_DIR_ . '/' . dirname(self::SETTINGS_FILE))) {
$this->setError($this->language->l('%s folder is not writable (check permissions)', dirname(self::SETTINGS_FILE)));
return false;
}
// Generate settings content and write file
$settings_constants = array('_DB_SERVER_' => $database_server, '_DB_NAME_' => $database_name, '_DB_USER_' => $database_login, '_DB_PASSWD_' => $database_password, '_DB_PREFIX_' => $database_prefix, '_MYSQL_ENGINE_' => $database_engine, '_PS_CACHING_SYSTEM_' => 'CacheMemcache', '_PS_CACHE_ENABLED_' => '0', '_MEDIA_SERVER_1_' => '', '_MEDIA_SERVER_2_' => '', '_MEDIA_SERVER_3_' => '', '_COOKIE_KEY_' => Tools::passwdGen(56), '_COOKIE_IV_' => Tools::passwdGen(8), '_PS_CREATION_DATE_' => date('Y-m-d'), '_PS_VERSION_' => _PS_INSTALL_VERSION_);
// If mcrypt is activated, add Rijndael 128 configuration
if (function_exists('mcrypt_encrypt')) {
$settings_constants['_RIJNDAEL_KEY_'] = Tools::passwdGen(mcrypt_get_key_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB));
$settings_constants['_RIJNDAEL_IV_'] = base64_encode(mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_ECB), MCRYPT_RAND));
}
$settings_content = "<?php\n";
foreach ($settings_constants as $constant => $value) {
$settings_content .= "define('{$constant}', '" . str_replace('\'', '\\\'', $value) . "');\n";
}
if (!file_put_contents(_PS_ROOT_DIR_ . '/' . self::SETTINGS_FILE, $settings_content)) {
$this->setError($this->language->l('Cannot write settings file'));
return false;
}
return true;
}
示例7: generateReference
public static function generateReference()
{
do {
$reference = strtoupper(Tools::passwdGen(9, 'NO_NUMERIC'));
} while (Order::getByReference($reference));
return $reference;
}
示例8: registerDiscount
public function registerDiscount($id_customer, $register = false)
{
$configurations = Configuration::getMultiple(array('REFERRAL_DISCOUNT_TYPE', 'REFERRAL_DISCOUNT_VALUE'));
$discount = new Discount();
$discount->id_discount_type = intval($configurations['REFERRAL_DISCOUNT_TYPE']);
$discount->value = floatval($configurations['REFERRAL_DISCOUNT_VALUE']);
$discount->quantity = 1;
$discount->quantity_per_user = 1;
$discount->date_from = date('Y-m-d H:i:s', time());
$discount->date_to = date('Y-m-d H:i:s', time() + 31536000);
// + 1 year
$discount->name = $this->getDiscountPrefix() . Tools::passwdGen(6);
$discount->description = Configuration::getInt('REFERRAL_DISCOUNT_DESCRIPTION');
$discount->id_customer = intval($id_customer);
if ($discount->add()) {
if ($register != false) {
if ($register == 'sponsor') {
$this->id_discount_sponsor = $discount->id;
} elseif ($register == 'sponsored') {
$this->id_discount = $discount->id;
}
return $this->save();
}
return true;
}
return false;
}
示例9: install
public function install()
{
if (!parent::install() || !$this->installExternalCarrier($this->_config) || !Configuration::updateValue('EXTERNAL_CARRIER_OVERCOST', 5) || !$this->registerHook('updateCarrier') || !$this->registerHook('extraCarrier') || !$this->registerHook('newOrder') || !$this->registerHook('processCarrier') || !$this->registerHook('orderDetailDisplayed') || !$this->registerHook('updateOrderStatus') || !Configuration::updateValue('KIALASMALL_VERSION', $this->version) || !Configuration::updateValue('KIALASMALL_SECURITY_TOKEN', Tools::passwdGen(30)) || !Configuration::updateValue('KIALASMALL_WS_URL', $this->ws_url) || !Configuration::updateValue('KIALASMALL_SEARCH_BY', 'order')) {
return false;
}
// Install SQL
include dirname(__FILE__) . '/sql-install.php';
foreach ($sql as $s) {
if (!Db::getInstance()->Execute($s)) {
return false;
}
}
// Create country settings
foreach ($this->countries as $iso_code) {
$id_country = Country::getByIso($iso_code);
if ($id_country) {
$kiala_country = new SmKialaCountry();
$kiala_country->id_country = $id_country;
$kiala_country->preparation_delay = $this->default_preparation_delay;
$kiala_country->active = 0;
// Is this the merchant home country?
if ($id_country == Country::getByIso('ES')) {
$kiala_country->pickup_country = 1;
$kiala_country->dspid = '34600160';
}
$kiala_country->save();
}
}
return true;
}
示例10: postProcess
/**
* Start forms process
* @see FrontController::postProcess()
*/
public function postProcess()
{
if (Tools::isSubmit('submitMessage')) {
$idOrder = (int) Tools::getValue('id_order');
$msgText = Tools::getValue('msgText');
if (!$idOrder || !Validate::isUnsignedId($idOrder)) {
$this->errors[] = Tools::displayError('The order is no longer valid.');
} elseif (empty($msgText)) {
$this->errors[] = Tools::displayError('The message cannot be blank.');
} elseif (!Validate::isMessage($msgText)) {
$this->errors[] = Tools::displayError('This message is invalid (HTML is not allowed).');
}
if (!count($this->errors)) {
$order = new Order($idOrder);
if (Validate::isLoadedObject($order) && $order->id_customer == $this->context->customer->id) {
//check if a thread already exist
$id_customer_thread = CustomerThread::getIdCustomerThreadByEmailAndIdOrder($this->context->customer->email, $order->id);
$cm = new CustomerMessage();
if (!$id_customer_thread) {
$ct = new CustomerThread();
$ct->id_contact = 0;
$ct->id_customer = (int) $order->id_customer;
$ct->id_shop = (int) $this->context->shop->id;
if (($id_product = (int) Tools::getValue('id_product')) && $order->orderContainProduct((int) $id_product)) {
$ct->id_product = $id_product;
}
$ct->id_order = (int) $order->id;
$ct->id_lang = (int) $this->context->language->id;
$ct->email = $this->context->customer->email;
$ct->status = 'open';
$ct->token = Tools::passwdGen(12);
$ct->add();
} else {
$ct = new CustomerThread((int) $id_customer_thread);
}
$cm->id_customer_thread = $ct->id;
$cm->message = $msgText;
$cm->ip_address = ip2long($_SERVER['REMOTE_ADDR']);
$cm->add();
if (!Configuration::get('PS_MAIL_EMAIL_MESSAGE')) {
$to = strval(Configuration::get('PS_SHOP_EMAIL'));
} else {
$to = new Contact((int) Configuration::get('PS_MAIL_EMAIL_MESSAGE'));
$to = strval($to->email);
}
$toName = strval(Configuration::get('PS_SHOP_NAME'));
$customer = $this->context->customer;
if (Validate::isLoadedObject($customer)) {
Mail::Send($this->context->language->id, 'order_customer_comment', Mail::l('Message from a customer'), array('{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{email}' => $customer->email, '{id_order}' => (int) $order->id, '{order_name}' => $order->getUniqReference(), '{message}' => Tools::nl2br($msgText)), $to, $toName, $customer->email, $customer->firstname . ' ' . $customer->lastname);
}
if (Tools::getValue('ajax') != 'true') {
Tools::redirect('index.php?controller=order-detail&id_order=' . (int) $idOrder);
}
$this->context->smarty->assign('message_confirmation', true);
} else {
$this->errors[] = Tools::displayError('Order not found');
}
}
}
}
示例11: createDefaultBcashDiscounts
public function createDefaultBcashDiscounts()
{
foreach ($this->names as $name) {
$coupon = new Discount();
$coupon->name = $this->getLangsForName($name);
$coupon->quantity = self::billion;
$coupon->quantity_per_user = self::billion;
$coupon->date_from = date('Y-m-d H:i:s');
$coupon->date_to = date('Y-m-d', strtotime('+30 year'));
$coupon->partial_use = 0;
$coupon->code = 'gerenciado_pelo_modulo_' . Tools::passwdGen(8);
$coupon->active = 0;
//Invisivel
$coupon->highlight = 0;
//Envio excluido
$coupon->minimum_amount_shipping = 0;
//Acoes
$coupon->free_shipping = 0;
$coupon->reduction_percent = 0;
if ($coupon->add()) {
Configuration::updateValue(self::prefix . self::bcash . $name, (int) $coupon->id);
}
}
return true;
}
示例12: install
public function install()
{
$ps_ct_immediat_payment = Configuration::get($this->prefix . 'IMMEDIAT_PAYMENT') ? Configuration::get($this->prefix . 'IMMEDIAT_PAYMENT') : '1';
$ps_ct_salt = Configuration::get($this->prefix . 'SALT') ? Configuration::get($this->prefix . 'SALT') : strtoupper(Tools::passwdGen(8));
$ps_ct_business_type = Configuration::get($this->prefix . 'BUSINESS_TYPE') ? Configuration::get($this->prefix . 'BUSINESS_TYPE') : 'I';
$ps_ct_environment = Configuration::get($this->prefix . 'ENVIRONMENT') ? Configuration::get($this->prefix . 'ENVIRONMENT') : 'T';
return parent::install() and Disposition::createTable() and $this->_createOrderState() and $this->registerHook('payment') and $this->registerHook('paymentReturn') and $this->registerHook('adminOrder') and Configuration::updateValue($this->prefix . 'IMMEDIAT_PAYMENT', $ps_ct_immediat_payment) and Configuration::updateValue($this->prefix . 'SALT', $ps_ct_salt) and Configuration::updateValue($this->prefix . 'BUSINESS_TYPE', $ps_ct_business_type) and Configuration::updateValue($this->prefix . 'ENVIRONMENT', $ps_ct_environment);
}
示例13: setCustomerInformation
/**
* Set customer information
* Used to create user account with PayPal account information
*/
function setCustomerInformation($ppec, $email)
{
$customer = new Customer();
$customer->email = $email;
$customer->lastname = $ppec->result['LASTNAME'];
$customer->firstname = $ppec->result['FIRSTNAME'];
$customer->passwd = Tools::encrypt(Tools::passwdGen());
return $customer;
}
示例14: __construct
/**
* Construct Method
*
**/
public function __construct()
{
$this->name = 'ebay';
$this->tab = 'market_place';
$this->version = '1.6.5';
$this->author = 'PrestaShop';
parent::__construct();
/** Backward compatibility */
require _PS_MODULE_DIR_ . $this->name . '/backward_compatibility/backward.php';
$this->displayName = $this->l('eBay');
$this->description = $this->l('Easily export your products from PrestaShop to eBay, the biggest market place, to acquire new customers and realize more sales.');
$this->module_key = '7a6b007a219bab59c1611254347f21d5';
$this->ps_versions_compliancy = array('min' => '1.4', 'max' => _PS_VERSION_);
// Checking Extension
$this->_checkExtensionsLoading();
// Checking compatibility with older PrestaShop and fixing it
if (!Configuration::get('PS_SHOP_DOMAIN')) {
$this->setConfiguration('PS_SHOP_DOMAIN', $_SERVER['HTTP_HOST']);
}
// Generate eBay Security Token if not exists
if (!Configuration::get('EBAY_SECURITY_TOKEN')) {
$this->setConfiguration('EBAY_SECURITY_TOKEN', Tools::passwdGen(30));
}
// For 1.4.3 and less compatibility
$update_config = array('PS_OS_CHEQUE' => 1, 'PS_OS_PAYMENT' => 2, 'PS_OS_PREPARATION' => 3, 'PS_OS_SHIPPING' => 4, 'PS_OS_DELIVERED' => 5, 'PS_OS_CANCELED' => 6, 'PS_OS_REFUND' => 7, 'PS_OS_ERROR' => 8, 'PS_OS_OUTOFSTOCK' => 9, 'PS_OS_BANKWIRE' => 10, 'PS_OS_PAYPAL' => 11, 'PS_OS_WS_PAYMENT' => 12);
foreach ($update_config as $key => $value) {
if (!Configuration::get($key)) {
$const_name = '_' . $key . '_';
if ((int) constant($const_name)) {
$this->setConfiguration($key, constant($const_name));
} else {
$this->setConfiguration($key, $value);
}
}
}
// Check if installed
if (self::isInstalled($this->name)) {
if (class_exists('EbayCountrySpec')) {
// Check the country
$this->ebay_country = EbayCountrySpec::getInstanceByKey(Configuration::get('EBAY_COUNTRY_DEFAULT'));
if (!$this->ebay_country->checkCountry()) {
$this->warning = $this->l('The eBay module currently works for eBay.fr, eBay.it, eBay.co.uk, eBay.pl, eBay.nl and eBay.es');
return false;
}
}
// Upgrade eBay module
if (Configuration::get('EBAY_VERSION') != $this->version) {
$this->_upgrade();
}
// Generate warnings
if (!Configuration::get('EBAY_API_TOKEN')) {
$this->warning = $this->l('You must register your module on eBay.');
}
// Warning uninstall
$this->confirmUninstall = $this->l('Are you sure you want to uninistall this module? All configuration settings will be lost');
}
}
示例15: postProcess
/**
* Start forms process
* @see FrontController::postProcess()
*/
public function postProcess()
{
if (Tools::isSubmit('email')) {
if (!($email = Tools::getValue('email')) || !Validate::isEmail($email)) {
$this->errors[] = Tools::displayError('Invalid e-mail address');
} else {
$customer = new Customer();
$customer->getByemail($email);
if (!Validate::isLoadedObject($customer)) {
$this->errors[] = Tools::displayError('There is no account registered to this e-mail address.');
} elseif (!$customer->active) {
$this->errors[] = Tools::displayError('You cannot regenerate the password for this account.');
} elseif (strtotime($customer->last_passwd_gen . '+' . (int) ($min_time = Configuration::get('PS_PASSWD_TIME_FRONT')) . ' minutes') - time() > 0) {
$this->errors[] = sprintf(Tools::displayError('You can regenerate your password only every %d minute(s)'), (int) $min_time);
} else {
$mail_params = array('{email}' => $customer->email, '{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{url}' => $this->context->link->getPageLink('password', true, null, 'token=' . $customer->secure_key . '&id_customer=' . (int) $customer->id));
if (Mail::Send($this->context->language->id, 'password_query', Mail::l('Password query confirmation'), $mail_params, $customer->email, $customer->firstname . ' ' . $customer->lastname)) {
$this->context->smarty->assign(array('confirmation' => 2, 'email' => $customer->email));
} else {
$this->errors[] = Tools::displayError('Error occurred while sending the e-mail.');
}
}
}
} elseif (($token = Tools::getValue('token')) && ($id_customer = (int) Tools::getValue('id_customer'))) {
$email = Db::getInstance()->getValue('SELECT `email` FROM ' . _DB_PREFIX_ . 'customer c WHERE c.`secure_key` = \'' . pSQL($token) . '\' AND c.id_customer = ' . (int) $id_customer);
if ($email) {
$customer = new Customer();
$customer->getByemail($email);
if (!Validate::isLoadedObject($customer)) {
$this->errors[] = Tools::displayError('Customer account not found');
} elseif (!$customer->active) {
$this->errors[] = Tools::displayError('You cannot regenerate the password for this account.');
} elseif (strtotime($customer->last_passwd_gen . '+' . (int) Configuration::get('PS_PASSWD_TIME_FRONT') . ' minutes') - time() > 0) {
Tools::redirect('index.php?controller=authentication&error_regen_pwd');
} else {
$customer->passwd = Tools::encrypt($password = Tools::passwdGen(MIN_PASSWD_LENGTH));
$customer->last_passwd_gen = date('Y-m-d H:i:s', time());
if ($customer->update()) {
Hook::exec('actionPasswordRenew', array('customer' => $customer, 'password' => $password));
$mail_params = array('{email}' => $customer->email, '{lastname}' => $customer->lastname, '{firstname}' => $customer->firstname, '{passwd}' => $password);
if (Mail::Send($this->context->language->id, 'password', Mail::l('Your new password'), $mail_params, $customer->email, $customer->firstname . ' ' . $customer->lastname)) {
$this->context->smarty->assign(array('confirmation' => 1, 'email' => $customer->email));
} else {
$this->errors[] = Tools::displayError('Error occurred while sending the e-mail.');
}
} else {
$this->errors[] = Tools::displayError('An error occurred with your account and your new password cannot be sent to your e-mail. Please report your problem using the contact form.');
}
}
} else {
$this->errors[] = Tools::displayError('We cannot regenerate your password with the data you submitted');
}
} elseif (Tools::getValue('token') || Tools::getValue('id_customer')) {
$this->errors[] = Tools::displayError('We cannot regenerate your password with the data you submitted');
}
}