本文整理汇总了PHP中Encryption类的典型用法代码示例。如果您正苦于以下问题:PHP Encryption类的具体用法?PHP Encryption怎么用?PHP Encryption使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Encryption类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: callback
public function callback()
{
$this->load->library('encryption');
$encryption = new Encryption($this->config->get('config_encryption'));
$order_id = $encryption->decrypt(@$this->request->get['order_id']);
$this->load->model('checkout/order');
$order_info = $this->model_checkout_order->getOrder($order_id);
if ($order_info) {
$req = 'cmd=_notify-validate';
foreach ($this->request->post as $key => $value) {
$req .= '&' . $key . '=' . urlencode(stripslashes($value));
}
$header = 'POST /cgi-bin/webscr HTTP/1.0' . "\r\n";
$header .= 'Content-Type: application/x-www-form-urlencoded' . "\r\n";
$header .= 'Content-Length: ' . strlen(utf8_decode($req)) . "\r\n\r\n";
if (!$this->config->get('paypal_test')) {
$fp = fsockopen('www.paypal.com', 80, $errno, $errstr, 30);
} else {
$fp = fsockopen('www.sandbox.paypal.com', 80, $errno, $errstr, 30);
}
if ($fp) {
fputs($fp, $header . $req);
while (!feof($fp)) {
$res = fgets($fp, 1024);
if (strcmp($res, 'VERIFIED') == 0) {
$this->model_checkout_order->confirm($order_id, $this->config->get('paypal_order_status_id'));
}
}
fclose($fp);
}
}
}
示例2: callback
public function callback()
{
$this->load->library('encryption');
$encryption = new Encryption($this->config->get('config_encryption'));
if (isset($this->request->post['custom'])) {
$order_id = $encryption->decrypt($this->request->post['custom']);
} else {
$order_id = 0;
}
$this->load->model('checkout/order');
$order_info = $this->model_checkout_order->getOrder($order_id);
if ($order_info) {
$request = 'cmd=_notify-validate';
foreach ($this->request->post as $key => $value) {
$request .= '&' . $key . '=' . urlencode(stripslashes(html_entity_decode($value, ENT_QUOTES, 'UTF-8')));
}
if (extension_loaded('curl')) {
if (!$this->config->get('pp_standard_test')) {
$ch = curl_init('https://www.paypal.com/cgi-bin/webscr');
} else {
$ch = curl_init('https://www.sandbox.paypal.com/cgi-bin/webscr');
}
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
if (strcmp($response, 'VERIFIED') == 0 || $this->request->post['payment_status'] == 'Completed') {
$this->model_checkout_order->confirm($order_id, $this->config->get('pp_standard_order_status_id'));
} else {
$this->model_checkout_order->confirm($order_id, $this->config->get('config_order_status_id'));
}
curl_close($ch);
} else {
$header = 'POST /cgi-bin/webscr HTTP/1.0' . "\r\n";
$header .= 'Content-Type: application/x-www-form-urlencoded' . "\r\n";
$header .= 'Content-Length: ' . strlen(utf8_decode($request)) . "\r\n";
$header .= 'Connection: close' . "\r\n\r\n";
if (!$this->config->get('pp_standard_test')) {
$fp = fsockopen('www.paypal.com', 80, $errno, $errstr, 30);
} else {
$fp = fsockopen('www.sandbox.paypal.com', 80, $errno, $errstr, 30);
}
if ($fp) {
fputs($fp, $header . $request);
while (!feof($fp)) {
$response = fgets($fp, 1024);
if (strcmp($response, 'VERIFIED') == 0) {
$this->model_checkout_order->confirm($order_id, $this->config->get('pp_standard_order_status_id'));
} else {
$this->model_checkout_order->confirm($order_id, $this->config->get('config_order_status_id'));
}
}
fclose($fp);
}
}
}
}
示例3: callback
public function callback()
{
$this->load->library('encryption');
$encryption = new Encryption($this->config->get('config_encryption'));
if (isset($this->request->post['order_id'])) {
$order_id = $encryption->decrypt($this->request->post['order_id']);
} else {
$order_id = 0;
}
$this->load->model('checkout/order');
$order_info = $this->model_checkout_order->getOrder($order_id);
if ($order_info) {
$this->model_checkout_order->confirm($order_id, $this->config->get('config_order_status_id'));
switch ($this->request->post['status']) {
case '2':
$this->model_checkout_order->update($order_id, $this->config->get('moneybookers_order_status_id'), '', TRUE);
break;
case '0':
$this->model_checkout_order->update($order_id, $this->config->get('moneybookers_order_status_pending_id'), '', TRUE);
break;
case '-1':
$this->model_checkout_order->update($order_id, $this->config->get('moneybookers_order_status_canceled_id'), '', TRUE);
break;
case '-2':
$this->model_checkout_order->update($order_id, $this->config->get('moneybookers_order_status_failed_id'), '', TRUE);
break;
case '-3':
$this->model_checkout_order->update($order_id, $this->config->get('moneybookers_order_status_chargeback_id'), '', TRUE);
break;
}
}
}
示例4: GeneratePrivateKey
function GeneratePrivateKey($a)
{
$auth = new Encryption();
$x = $auth->ReadFolder($a);
$y = $auth->PickRandomImages($x);
$z = $auth->GeneratePrivKey($y);
return $z;
}
示例5: reorder
protected function reorder()
{
$this->data['button_confirm'] = $this->language->get('button_reoder_confirm');
$this->data['button_back'] = $this->language->get('button_back');
$this->data['return'] = HTTPS_SERVER . 'index.php?route=account/paysuccess';
$this->load->library('encryption');
$encryption = new Encryption($this->config->get('config_encryption'));
//$order_id=$this->request->get['order_id'];
if (isset($this->request->get['order_id'])) {
$order_id = $this->request->get['order_id'];
} else {
$order_id = $this->session->data['zb_cart_orderid'];
}
$this->data['custom'] = $encryption->encrypt($order_id);
$this->load->model('checkout/order');
$order_info = $this->model_checkout_order->getOrder($order_id);
$this->data['order_info'] = $order_info;
$currency_code = 'CNY';
$item_name = $this->config->get('config_title');
$first_name = $order_info['payment_firstname'];
$last_name = $order_info['payment_lastname'];
$cmdno = $this->config->get('tenpay_cmdno');
// 接口类型
$mch_type = $this->config->get('tenpay_mch_type');
// 虚拟物品还是实际物品
/* 平台商密钥 */
$key = $this->config->get('tenpay_key');
/* 平台商帐号 */
$chnid = $this->config->get('tenpay_bargainor_id');
/* 卖家 */
$seller = $this->config->get('tenpay_seller');
$total = $order_info['total'];
$currency_value = $this->currency->getValue($currency_code);
$amount = $total * $currency_value;
$amount = number_format($amount, 2, '.', '');
$charset = 2;
//编码类型 1:gbk 2:utf-8
$notify_url = HTTPS_SERVER . 'catalog/controller/payment/tenpay_callback.php';
$return_url = HTTPS_SERVER . 'index.php?route=account/paysuccess';
$data = array('bargainor_id' => $chnid, 'chnid' => $chnid, 'seller' => $seller, 'key' => $key, 'order_id' => $order_id, 'total_fee' => $amount * 100, 'store' => $item_name, 'callback' => $notify_url, 'return' => $return_url);
if ($cmdno == '12') {
// 中介担保支付
$action = $this->mediPay($data);
} else {
// 直接支付
$action = $this->pay($data);
}
$this->data['reorder'] = true;
$this->data['action'] = $action;
$this->id = 'payment';
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/tenpay.tpl')) {
$this->template = $this->config->get('config_template') . '/template/payment/tenpay.tpl';
} else {
$this->template = 'default/template/payment/tenpay.tpl';
}
$this->render();
}
示例6: testEncrypt
/**
* Tests encryption
*/
public function testEncrypt()
{
$string = "this is a test string";
$enc = new Encryption();
$encrypted = $enc->encode($string);
$this->assertTrue($encrypted != $string);
$unencrypted = $enc->decode($encrypted);
$this->assertTrue($unencrypted == $string);
}
示例7: get_open
public function get_open()
{
global $ost, $cfg;
define('MY_DEBUG', isset($_GET['debug']) && $_GET['debug'] === '1');
$topic_names = Topic::getPublicHelpTopics();
if (isset($_GET['topics'])) {
$allowed_topics = [];
if (is_array($_GET['topics'])) {
$allowed_topics = $_GET['topics'];
} else {
$allowed_topics = [$_GET['topics']];
}
$topic_names = array_filter($topic_names, function ($name, $id) use($allowed_topics) {
return in_array($id, $allowed_topics) || in_array($name, $allowed_topics);
}, ARRAY_FILTER_USE_BOTH);
}
$formPrefix = $this->config->get('ajax_submission_form_prefix');
$csrf_token = $ost->getCSRF()->getToken();
$topics = [];
foreach ($topic_names as $id => $name) {
if (($topic = Topic::lookup($id)) && ($form = $topic->getForm()) && ($fields = $form->getForm()->getFields())) {
$topics[$id] = ['name' => $name, 'instructions' => $form->get('instructions'), 'fields' => []];
foreach ($fields as $field) {
$topics[$id]['fields'][$field->get('name')] = ['name' => $formPrefix . $field->get('name'), 'type' => $field->get('type')];
if ($field->get('type') === 'choices') {
$topics[$id]['fields'][$field->get('name')]['choices'] = $field->getChoices();
}
}
}
}
$captcha = null;
$useCaptcha = $this->config->get('ajax_submission_captcha');
if ($useCaptcha === 1) {
// built-in
$captcha = ['type' => 'osTicket'];
} elseif ($useCaptcha === 2) {
// recaptcha
$public = $this->config->get('ajax_recaptcha_site');
$private = $this->config->get('ajax_recaptcha_secret');
if ($public && $private) {
// Key creation based on https://github.com/google/recaptcha-java/blob/master/appengine/src/main/java/com/google/recaptcha/STokenUtils.java
$encrypter = new Encryption(substr(hash('sha1', $private, true), 0, 16));
$secure_token = json_encode(['session_id' => uniqid($csrf_token), 'ts_ms' => bcmul(microtime(true), 1000, 0)]);
$captcha = ['type' => 'reCaptcha', 'public_key' => $public, 'secure_token' => $encrypter->encrypt_aes_ecb_pkcs5($secure_token)];
} else {
throw new Exception('reCaptcha key not provided!');
}
}
$return = ['method' => 'POST', 'submit_url' => self::baseURL() . '/ajax.php/ajax-form/submit', 'form_groups' => ['backend' => ['hidden' => true, fields => ['csrf', 'action']], 'topic' => ['legend' => 'Help Topic', fields => ['topicId']], 'user' => ['legend' => 'Contact Information', fields => ['name', 'email', 'phone']], 'topic_details' => ['dynamic' => true, 'id' => $formPrefix . 'topic_details'], 'ticket' => ['legend' => 'Ticket Details', fields => ['summary', 'details']]], 'form_fields' => ['csrf' => ['type' => 'hidden', 'value' => $csrf_token, 'name' => $formPrefix . $ost->getCSRF()->getTokenName()], 'action' => ['type' => 'hidden', 'value' => 'open', 'name' => $formPrefix . 'a'], 'topicId' => ['label' => 'Select a Topic', 'required' => true, 'type' => 'choices', 'name' => $formPrefix . 'topicId', 'choices' => $topic_names], 'name' => ['label' => 'Full Name', 'required' => true, 'type' => 'text', 'name' => $formPrefix . 'name'], 'email' => ['label' => 'Email Address', 'required' => true, 'type' => 'text', 'name' => $formPrefix . 'email'], 'phone' => ['label' => 'Phone Number', 'required' => true, 'type' => 'text', 'name' => $formPrefix . 'phone'], 'summary' => ['label' => 'Issue Summary', 'required' => true, 'type' => 'text', 'name' => $formPrefix . 'summary'], 'details' => ['label' => 'Issue Details', 'required' => true, 'type' => 'textarea', 'name' => $formPrefix . 'details']], 'topics' => $topics, 'captcha' => $captcha];
header('Access-Control-Allow-Origin: ' . $this->config->get('ajax_cors_header'));
$json_flags = 0;
if (MY_DEBUG) {
$json_flags += JSON_PRETTY_PRINT;
}
return json_encode($return, $json_flags);
}
示例8: getcookies
function getcookies()
{
$crypt = new Encryption();
$this->array = array();
if (isset($_COOKIE[$this->name])) {
foreach ($_COOKIE[$this->name] as $key => $value) {
$this->array[$key] = $crypt->decode($value);
}
}
}
示例9: __crypt
/**
* Encrypt/Decrypt input.
* @access private
*/
function __crypt($password, $encrypt = true)
{
require_once 'include/utils/encryption.php';
$cryptobj = new Encryption();
if ($encrypt) {
return $cryptobj->encrypt(trim($password));
} else {
return $cryptobj->decrypt(trim($password));
}
}
示例10: MailBox
function MailBox($mailbox = '', $p = '', $s = '')
{
global $current_user;
require_once 'include/utils/encryption.php';
$oencrypt = new Encryption();
$this->db = PearDatabase::getInstance();
$this->db->println("Entering MailBox({$mailbox})");
$this->mailbox = $mailbox;
$tmp = getMailServerInfo($current_user);
if ($this->db->num_rows($tmp) < 1) {
$this->enabled = 'false';
} else {
$this->enabled = 'true';
}
$this->boxinfo = $this->db->fetch_array($tmp);
$this->login_username = trim($this->boxinfo["mail_username"]);
$this->secretkey = $oencrypt->decrypt(trim($this->boxinfo["mail_password"]));
$this->imapServerAddress = gethostbyname(trim($this->boxinfo["mail_servername"]));
$this->mail_protocol = $this->boxinfo["mail_protocol"];
$this->ssltype = $this->boxinfo["ssltype"];
$this->sslmeth = $this->boxinfo["sslmeth"];
$this->box_refresh = trim($this->boxinfo["box_refresh"]);
$this->mails_per_page = trim($this->boxinfo["mails_per_page"]);
if ($this->mails_per_page < 1) {
$this->mails_per_page = 20;
}
$this->account_name = $this->boxinfo["account_name"];
$this->display_name = $this->boxinfo["display_name"];
//$this->imapServerAddress=$this->boxinfo["mail_servername"];
$this->db->println("Setting Mailbox Name");
if ($this->mailbox != "") {
$this->mailbox = $mailbox;
}
$this->db->println("Opening Mailbox");
if (!$this->mbox && $this->mailbox != "") {
$this->getImapMbox();
}
$this->db->println("Loading mail list");
$pa = $p;
$se = $s;
if ($this->mbox) {
if ($se != "") {
$this->mailList = $this->searchMailList($se, $pa);
} else {
if ($pa == "") {
$this->mailList = $this->customMailList(0);
} else {
$this->mailList = $this->customMailList($pa);
}
}
}
$this->db->println("Exiting MailBox({$mailbox})");
}
示例11: index
public function index()
{
$data['button_confirm'] = $this->language->get('button_confirm');
$data['button_back'] = $this->language->get('button_back');
$data['return'] = HTTPS_SERVER . 'index.php?route=checkout/success';
if ($this->request->get['route'] != 'checkout/guest_step_3') {
$data['cancel_return'] = HTTPS_SERVER . 'index.php?route=checkout/payment';
} else {
$data['cancel_return'] = HTTPS_SERVER . 'index.php?route=checkout/guest_step_2';
}
$this->load->library('encryption');
$encryption = new Encryption($this->config->get('config_encryption'));
$data['custom'] = $encryption->encrypt($this->session->data['order_id']);
if ($this->request->get['route'] != 'checkout/guest_step_3') {
$data['back'] = HTTPS_SERVER . 'index.php?route=checkout/payment';
} else {
$data['back'] = HTTPS_SERVER . 'index.php?route=checkout/guest_step_2';
}
$this->load->model('checkout/order');
$order_id = $this->session->data['order_id'];
$order_info = $this->model_checkout_order->getOrder($order_id);
$seller_email = $this->config->get('alipay_seller_email');
$security_code = $this->config->get('alipay_security_code');
$trade_type = $this->config->get('alipay_trade_type');
$partner = $this->config->get('alipay_partner');
$currency_code = 'CNY';
$item_name = $this->config->get('config_name');
$full_name = $order_info['payment_fullname'];
$total = $order_info['total'];
$currency_value = $this->currency->getValue($currency_code);
$amount = $total * $currency_value;
$amount = number_format($amount, 2, '.', '');
$_input_charset = "utf-8";
$sign_type = "MD5";
$transport = "http";
$notify_url = HTTP_SERVER . 'catalog/controller/payment/alipay_callback.php';
$return_url = HTTPS_SERVER . 'index.php?route=checkout/success';
$show_url = "";
$parameter = array("service" => $trade_type, "partner" => $partner, "return_url" => $return_url, "notify_url" => $notify_url, "_input_charset" => $_input_charset, "subject" => $item_name . ' Order:' . $order_id, "body" => 'Owner ' . $full_name, "out_trade_no" => $order_id, "price" => $amount, "payment_type" => "1", "quantity" => "1", "logistics_fee" => '0.00', "logistics_payment" => 'BUYER_PAY', "logistics_type" => 'EXPRESS', "show_url" => $show_url, "seller_email" => $seller_email);
$alipay = new alipay_service($parameter, $security_code, $sign_type);
$action = $alipay->build_url();
$data['action'] = $action;
//$this->id = 'payment';
// Save payment url address for pay later.
$this->model_checkout_order->setOrderPaymentUrl($order_id, $action);
// log_result("Alipay test 111111111111");
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/alipay.tpl')) {
return $this->load->view($this->config->get('config_template') . '/template/payment/alipay.tpl', $data);
} else {
return $this->load->view('default/template/payment/alipay.tpl', $data);
}
}
示例12: callback
public function callback()
{
$this->load->library('encryption');
$encryption = new Encryption($this->config->get('config_encryption'));
if (isset($this->request->post['order_id'])) {
$order_id = $encryption->decrypt($this->request->post['order_id']);
} else {
$order_id = 0;
}
$this->load->model('checkout/order');
$order_info = $this->model_checkout_order->getOrder($order_id);
if ($order_info) {
$this->model_checkout_order->confirm($order_id, $this->config->get('config_order_status_id'));
$verified = true;
// md5sig validation
if ($this->config->get('moneybookers_secret')) {
$hash = $this->request->post['merchant_id'];
$hash .= $this->request->post['transaction_id'];
$hash .= strtoupper(md5($this->config->get('moneybookers_secret')));
$hash .= $this->request->post['mb_amount'];
$hash .= $this->request->post['mb_currency'];
$hash .= $this->request->post['status'];
$md5hash = strtoupper(md5($hash));
$md5sig = $this->request->post['md5sig'];
if ($md5hash != $md5sig) {
$verified = false;
}
}
if ($verified) {
switch ($this->request->post['status']) {
case '2':
$this->model_checkout_order->update($order_id, $this->config->get('moneybookers_order_status_id'), '', TRUE);
break;
case '0':
$this->model_checkout_order->update($order_id, $this->config->get('moneybookers_pending_status_id'), '', TRUE);
break;
case '-1':
$this->model_checkout_order->update($order_id, $this->config->get('moneybookers_canceled_status_id'), '', TRUE);
break;
case '-2':
$this->model_checkout_order->update($order_id, $this->config->get('moneybookers_failed_status_id'), '', TRUE);
break;
case '-3':
$this->model_checkout_order->update($order_id, $this->config->get('moneybookers_chargeback_status_id'), '', TRUE);
break;
}
} else {
$this->log->write('md5sig returned (' + $md5sig + ') does not match generated (' + $md5hash + '). Verify Manually. Current order state: ' . $this->config->get('config_order_status_id'));
}
}
}
示例13: reorder
public function reorder()
{
$this->data['button_confirm'] = $this->language->get('button_reoder_confirm');
$this->data['button_back'] = $this->language->get('button_back');
$this->data['return'] = $this->url->link('checkout/success', '', 'SSL');
$this->load->library('encryption');
$encryption = new Encryption($this->config->get('config_encryption'));
if (isset($this->request->get['order_id'])) {
$order_id = $this->request->get['order_id'];
} else {
$order_id = $this->session->data['zb_cart_orderid'];
}
$this->data['custom'] = $encryption->encrypt($order_id);
$this->load->model('checkout/order');
$order_info = $this->model_checkout_order->getOrder($order_id);
$this->data['order_info'] = $order_info;
$order_totals = $this->model_checkout_order->Gettotals($order_id);
$seller_email = $this->config->get('alipay_seller_email');
$security_code = $this->config->get('alipay_security_code');
$trade_type = $this->config->get('alipay_trade_type');
$partner = $this->config->get('alipay_partner');
$currency_code = 'CNY';
$item_name = $this->config->get('config_name');
$first_name = $order_info['payment_firstname'];
$last_name = $order_info['payment_lastname'];
$total = $order_info['total'];
$currency_value = $this->currency->getValue($currency_code);
$amount = $total * $currency_value;
$amount = number_format($amount, 2, '.', '');
$_input_charset = "utf-8";
$sign_type = "MD5";
$transport = "http";
$notify_url = HTTP_SERVER . 'catalog/controller/payment/alipay_notify.php';
$return_url = HTTPS_SERVER . 'index.php?route=checkout/success';
$show_url = "";
$parameter = array("service" => $trade_type, "partner" => $partner, "return_url" => $return_url, "notify_url" => $notify_url, "_input_charset" => $_input_charset, "subject" => $item_name . $this->language->get('text_order_no') . $order_id, "body" => $item_name, "out_trade_no" => $order_id, "price" => $amount, "payment_type" => "1", "quantity" => "1", "logistics_fee" => '0.00', "logistics_payment" => 'BUYER_PAY', "logistics_type" => 'EXPRESS', "show_url" => $show_url, "seller_email" => $seller_email);
$alipay = new alipay_service($parameter, $security_code, $sign_type);
$action = $alipay->build_url();
$this->data['reorder'] = true;
$this->data['action'] = $action;
$this->id = 'payment';
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/alipay.tpl')) {
$this->template = $this->config->get('config_template') . '/template/payment/alipay.tpl';
} else {
$this->template = 'default/template/payment/alipay.tpl';
}
$this->render();
}
示例14: executeViewEmail
public function executeViewEmail(sfWebRequest $request)
{
sfConfig::set('sf_web_debug', false);
$this->setLayout(false);
$reservation_id = $request->getParameter('id');
$template = $request->getParameter('template');
$type = $request->getParameter('type');
$reservation = Doctrine::getTable('Reservation')->find($reservation_id);
// $url = sprintf('http://%s/access/%s',
// sfConfig::get('app_domain_name', $_SERVER['SERVER_NAME']),
// Encryption::encodeUrl('reservation', 'access', array(
// 'user_id' => $reservation->Client->User->id,
// 'uniqid' => $reservation->uniqid
// ))
// );
$url = sprintf('http://%s/access/%s', sfConfig::get('app_domain_name', $_SERVER['SERVER_NAME']), Encryption::getEncryptedUrlFromUri('@reservation_show?uniqid=' . $reservation->uniqid, $reservation->Client->User->id));
$data['reservation'] = $reservation;
$data['url'] = $url;
$data['subject'] = 'Subject';
$filename = $template . '_' . $type;
$message = new esEmailMessage('Test Email');
$message->setFrom(sfConfig::get('app_email_from'));
$message->setTo('some@mail.com');
$message->setAutoEmbedImages(false);
$message->setBodyFromTemplate($this->getController(), 'reservation', $filename, $data, $type == 'html' ? 'email_layout' : 'none');
return $this->renderText($message->getBody());
}
示例15: execute
/**
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @return int|void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->detectContao($output, true);
if ($this->initContao()) {
// Username
if (($username = $input->getArgument('username')) === null) {
$dialog = $this->getHelperSet()->get('dialog');
$username = $dialog->ask($output, '<question>Username:</question>');
}
// Email
if (($email = $input->getArgument('email')) === null) {
$dialog = $this->getHelperSet()->get('dialog');
$email = $dialog->ask($output, '<question>Email:</question>');
}
// Password
if (($password = $input->getArgument('password')) === null) {
$dialog = $this->getHelperSet()->get('dialog');
$password = $dialog->ask($output, '<question>Password:</question>');
}
// Name
if (($name = $input->getArgument('name')) === null) {
$dialog = $this->getHelperSet()->get('dialog');
$name = $dialog->ask($output, '<question>Name:</question>');
}
// create new user
$user = new \UserModel();
$user->setRow(array('username' => $username, 'name' => $name, 'email' => $email, 'password' => \Encryption::hash($password), 'admin' => 1))->save();
$user->save();
$output->writeln('<info>User <comment>' . $username . '</comment> successfully created</info>');
}
}