当前位置: 首页>>代码示例>>PHP>>正文


PHP hash_rand函数代码示例

本文整理汇总了PHP中hash_rand函数的典型用法代码示例。如果您正苦于以下问题:PHP hash_rand函数的具体用法?PHP hash_rand怎么用?PHP hash_rand使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了hash_rand函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: editAffiliate

 public function editAffiliate($affiliate_id, $data)
 {
     $this->db->query("UPDATE " . DB_PREFIX . "affiliate SET firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', fax = '" . $this->db->escape($data['fax']) . "', company = '" . $this->db->escape($data['company']) . "', address_1 = '" . $this->db->escape($data['address_1']) . "', address_2 = '" . $this->db->escape($data['address_2']) . "', city = '" . $this->db->escape($data['city']) . "', postcode = '" . $this->db->escape($data['postcode']) . "', country_id = '" . (int) $data['country_id'] . "', zone_id = '" . (int) $data['zone_id'] . "', code = '" . $this->db->escape($data['code']) . "', commission = '" . (double) $data['commission'] . "', tax = '" . $this->db->escape($data['tax']) . "', payment = '" . $this->db->escape($data['payment']) . "', cheque = '" . $this->db->escape($data['cheque']) . "', paypal = '" . $this->db->escape($data['paypal']) . "', bank_name = '" . $this->db->escape($data['bank_name']) . "', bank_branch_number = '" . $this->db->escape($data['bank_branch_number']) . "', bank_swift_code = '" . $this->db->escape($data['bank_swift_code']) . "', bank_account_name = '" . $this->db->escape($data['bank_account_name']) . "', bank_account_number = '" . $this->db->escape($data['bank_account_number']) . "', status = '" . (int) $data['status'] . "' WHERE affiliate_id = '" . (int) $affiliate_id . "'");
     if ($data['password']) {
         $this->db->query("UPDATE " . DB_PREFIX . "affiliate SET salt = '" . $this->db->escape($salt = substr(hash_rand('md5'), 0, 9)) . "', password = '" . $this->db->escape(sha1($salt . sha1($salt . sha1($data['password'])))) . "' WHERE affiliate_id = '" . (int) $affiliate_id . "'");
     }
 }
开发者ID:xanderwp,项目名称:opencart-ce,代码行数:7,代码来源:affiliate.php

示例2: mysql

 public function mysql($data)
 {
     $db = new DB($data['db_driver'], $data['db_host'], $data['db_user'], $data['db_password'], $data['db_name']);
     $file = DIR_APPLICATION . 'opencart.sql';
     if (!file_exists($file)) {
         exit('Could not load sql file: ' . $file);
     }
     $lines = file($file);
     if ($lines) {
         $sql = '';
         foreach ($lines as $line) {
             if ($line && substr($line, 0, 2) != '--' && substr($line, 0, 1) != '#') {
                 $sql .= $line;
                 if (preg_match('/;\\s*$/', $line)) {
                     $sql = str_replace("DROP TABLE IF EXISTS `oc_", "DROP TABLE IF EXISTS `" . $data['db_prefix'], $sql);
                     $sql = str_replace("CREATE TABLE `oc_", "CREATE TABLE `" . $data['db_prefix'], $sql);
                     $sql = str_replace("INSERT INTO `oc_", "INSERT INTO `" . $data['db_prefix'], $sql);
                     $db->query($sql);
                     $sql = '';
                 }
             }
         }
         $db->query("SET CHARACTER SET utf8");
         $db->query("SET @@session.sql_mode = 'MYSQL40'");
         $db->query("DELETE FROM `" . $data['db_prefix'] . "user` WHERE user_id = '1'");
         $db->query("INSERT INTO `" . $data['db_prefix'] . "user` SET user_id = '1', user_group_id = '1', username = '" . $db->escape($data['username']) . "', salt = '" . $db->escape($salt = substr(md5(uniqid(rand(), true)), 0, 9)) . "', password = '" . $db->escape(sha1($salt . sha1($salt . sha1($data['password'])))) . "', status = '1', email = '" . $db->escape($data['email']) . "', date_added = NOW()");
         $db->query("DELETE FROM `" . $data['db_prefix'] . "setting` WHERE `key` = 'config_email'");
         $db->query("INSERT INTO `" . $data['db_prefix'] . "setting` SET `group` = 'config', `key` = 'config_email', value = '" . $db->escape($data['email']) . "'");
         $db->query("DELETE FROM `" . $data['db_prefix'] . "setting` WHERE `key` = 'config_url'");
         $db->query("INSERT INTO `" . $data['db_prefix'] . "setting` SET `group` = 'config', `key` = 'config_url', value = '" . $db->escape(HTTP_OPENCART) . "'");
         $db->query("DELETE FROM `" . $data['db_prefix'] . "setting` WHERE `key` = 'config_encryption'");
         $db->query("INSERT INTO `" . $data['db_prefix'] . "setting` SET `group` = 'config', `key` = 'config_encryption', value = '" . $db->escape(hash_rand('md5')) . "'");
         $db->query("UPDATE `" . $data['db_prefix'] . "product` SET `viewed` = '0'");
     }
 }
开发者ID:xanderwp,项目名称:opencart-ce,代码行数:35,代码来源:install.php

示例3: index

 public function index()
 {
     if (!$this->config->get('config_password')) {
         $this->redirect($this->url->link('common/login', '', 'SSL'));
     }
     $this->language->load('common/forgotten');
     $this->document->setTitle($this->language->get('heading_title'));
     $this->load->model('user/user');
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate()) {
         $this->language->load('mail/forgotten');
         $code = hash_rand('sha1');
         $this->model_user_user->editCode($this->request->post['email'], $code);
         $subject = sprintf($this->language->get('text_subject'), $this->config->get('config_name'));
         $message = sprintf($this->language->get('text_greeting'), $this->config->get('config_name')) . "\n\n";
         $message .= sprintf($this->language->get('text_change'), $this->config->get('config_name')) . "\n\n";
         $message .= $this->url->link('common/reset', 'code=' . $code, 'SSL') . "\n\n";
         $message .= sprintf($this->language->get('text_ip'), $this->request->server['REMOTE_ADDR']) . "\n\n";
         $mail = new Mail();
         $mail->protocol = $this->config->get('config_mail_protocol');
         $mail->parameter = $this->config->get('config_mail_parameter');
         $mail->hostname = $this->config->get('config_smtp_host');
         $mail->username = $this->config->get('config_smtp_username');
         $mail->password = $this->config->get('config_smtp_password');
         $mail->port = $this->config->get('config_smtp_port');
         $mail->timeout = $this->config->get('config_smtp_timeout');
         $mail->setTo($this->request->post['email']);
         $mail->setFrom($this->config->get('config_email'));
         $mail->setSender($this->config->get('config_name'));
         $mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'));
         $mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
         $mail->send();
         $this->session->data['success'] = $this->language->get('text_success');
         $this->redirect($this->url->link('common/login', '', 'SSL'));
     }
     $this->data['breadcrumbs'] = array();
     $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home', '', 'SSL'), 'separator' => false);
     $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_forgotten'), 'href' => $this->url->link('common/forgotten', '', 'SSL'), 'separator' => $this->language->get('text_separator'));
     $this->data['heading_title'] = $this->language->get('heading_title');
     $this->data['text_your_email'] = $this->language->get('text_your_email');
     $this->data['text_email'] = $this->language->get('text_email');
     $this->data['entry_email'] = $this->language->get('entry_email');
     $this->data['button_reset'] = $this->language->get('button_reset');
     $this->data['button_cancel'] = $this->language->get('button_cancel');
     if (isset($this->error['warning'])) {
         $this->data['error_warning'] = $this->error['warning'];
     } else {
         $this->data['error_warning'] = '';
     }
     $this->data['action'] = $this->url->link('common/forgotten', '', 'SSL');
     $this->data['cancel'] = $this->url->link('common/login', '', 'SSL');
     if (isset($this->request->post['email'])) {
         $this->data['email'] = $this->request->post['email'];
     } else {
         $this->data['email'] = '';
     }
     $this->template = 'common/forgotten.tpl';
     $this->children = array('common/header', 'common/footer');
     $this->response->setOutput($this->render());
 }
开发者ID:ahmatjan,项目名称:OpenCart-Overclocked,代码行数:59,代码来源:forgotten.php

示例4: index

 public function index()
 {
     $this->language->load('tool/upload');
     $json = array();
     if (!empty($this->request->files['file']['name']) && is_file($this->request->files['file']['tmp_name'])) {
         // Sanitize the filename
         $filename = basename(preg_replace('/[^a-zA-Z0-9\\.\\-\\s+]/', '', html_entity_decode($this->request->files['file']['name'], ENT_QUOTES, 'UTF-8')));
         // Validate the filename length
         if (utf8_strlen($filename) < 3 || utf8_strlen($filename) > 64) {
             $json['error'] = $this->language->get('error_filename');
         }
         // Allowed file extension types
         $allowed = array();
         $extension_allowed = preg_replace('~\\r?\\n~', "\n", $this->config->get('config_file_ext_allowed'));
         $filetypes = explode("\n", $extension_allowed);
         foreach ($filetypes as $filetype) {
             $allowed[] = trim($filetype);
         }
         if (!in_array(strtolower(substr(strrchr($filename, '.'), 1)), $allowed)) {
             $json['error'] = $this->language->get('error_filetype');
         }
         // Allowed file mime types
         $allowed = array();
         $mime_allowed = preg_replace('~\\r?\\n~', "\n", $this->config->get('config_file_mime_allowed'));
         $filetypes = explode("\n", $mime_allowed);
         foreach ($filetypes as $filetype) {
             $allowed[] = trim($filetype);
         }
         if (!in_array($this->request->files['file']['type'], $allowed)) {
             $json['error'] = $this->language->get('error_filetype');
         }
         // Check to see if any PHP files are trying to be uploaded
         $content = file_get_contents($this->request->files['file']['tmp_name']);
         if (preg_match('/\\<\\?php/i', $content)) {
             $json['error'] = $this->language->get('error_filetype');
         }
         // Return any upload error
         if ($this->request->files['file']['error'] != UPLOAD_ERR_OK) {
             $json['error'] = $this->language->get('error_upload_' . $this->request->files['file']['error']);
         }
     } else {
         $json['error'] = $this->language->get('error_upload');
     }
     clearstatcache();
     if (!$json && is_uploaded_file($this->request->files['file']['tmp_name']) && file_exists($this->request->files['file']['tmp_name'])) {
         $file = basename($filename) . '.' . hash_rand('md5');
         move_uploaded_file($this->request->files['file']['tmp_name'], DIR_UPLOAD . $file);
         // Hide the uploaded file name so people can not link to it directly.
         $this->load->model('tool/upload');
         $json['code'] = $this->model_tool_upload->addUpload($filename, $file);
         $json['success'] = $this->language->get('text_upload');
     }
     $this->response->addHeader('Content-Type: application/json');
     $this->response->setOutput(json_encode($json));
 }
开发者ID:ahmatjan,项目名称:OpenCart-Overclocked,代码行数:55,代码来源:upload.php

示例5: editCustomer

 public function editCustomer($customer_id, $data)
 {
     $this->db->query("UPDATE " . DB_PREFIX . "customer SET firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', email = '" . $this->db->escape($data['email']) . "', telephone = '" . $this->db->escape($data['telephone']) . "', fax = '" . (isset($data['fax']) ? (int) $data['fax'] : 0) . "', gender = '" . (isset($data['gender']) ? (int) $data['gender'] : 0) . "', date_of_birth = '" . $this->db->escape($data['date_of_birth']) . "', newsletter = '" . (int) $data['newsletter'] . "', customer_group_id = '" . (int) $data['customer_group_id'] . "', status = '" . (int) $data['status'] . "', approved = '" . (int) $data['approved'] . "' WHERE customer_id = '" . (int) $customer_id . "'");
     if ($data['password']) {
         $this->db->query("UPDATE " . DB_PREFIX . "customer SET salt = '" . $this->db->escape($salt = substr(hash_rand('md5'), 0, 9)) . "', password = '" . $this->db->escape(sha1($salt . sha1($salt . sha1($data['password'])))) . "' WHERE customer_id = '" . (int) $customer_id . "'");
     }
     $this->db->query("DELETE FROM " . DB_PREFIX . "address WHERE customer_id = '" . (int) $customer_id . "'");
     if (isset($data['address'])) {
         foreach ($data['address'] as $address) {
             $this->db->query("INSERT INTO " . DB_PREFIX . "address SET address_id = '" . (int) $address['address_id'] . "', customer_id = '" . (int) $customer_id . "', firstname = '" . $this->db->escape($address['firstname']) . "', lastname = '" . $this->db->escape($address['lastname']) . "', company = '" . $this->db->escape($address['company']) . "', company_id = '" . $this->db->escape($address['company_id']) . "', tax_id = '" . $this->db->escape($address['tax_id']) . "', address_1 = '" . $this->db->escape($address['address_1']) . "', address_2 = '" . $this->db->escape($address['address_2']) . "', city = '" . $this->db->escape($address['city']) . "', postcode = '" . $this->db->escape($address['postcode']) . "', country_id = '" . (int) $address['country_id'] . "', zone_id = '" . (int) $address['zone_id'] . "'");
             if (isset($address['default'])) {
                 $address_id = $this->db->getLastId();
                 $this->db->query("UPDATE " . DB_PREFIX . "customer SET address_id = '" . (int) $address_id . "' WHERE customer_id = '" . (int) $customer_id . "'");
             }
         }
     }
 }
开发者ID:ahmatjan,项目名称:OpenCart-Overclocked,代码行数:17,代码来源:customer.php

示例6: editPassword

 public function editPassword($user_id, $password)
 {
     $this->db->query("UPDATE `" . DB_PREFIX . "user` SET salt = '" . $this->db->escape($salt = substr(hash_rand('md5'), 0, 9)) . "', password = '" . $this->db->escape(sha1($salt . sha1($salt . sha1($password)))) . "', code = '' WHERE user_id = '" . (int) $user_id . "'");
 }
开发者ID:skyosev,项目名称:OpenCart-Overclocked,代码行数:4,代码来源:user.php

示例7: index

 public function index()
 {
     $this->language->load('common/login');
     $this->document->setTitle($this->language->get('heading_title'));
     if ($this->user->isLogged() && isset($this->request->get['token']) && $this->request->get['token'] == $this->session->data['token']) {
         $this->redirect($this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'));
     }
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate()) {
         $this->session->data['token'] = hash_rand('md5');
         if (isset($this->request->post['redirect']) && (strpos($this->request->post['redirect'], HTTP_SERVER) === 0 || strpos($this->request->post['redirect'], HTTPS_SERVER) === 0)) {
             $this->redirect($this->request->post['redirect'] . '&token=' . $this->session->data['token']);
         } else {
             $this->redirect($this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'));
         }
     }
     $this->data['heading_title'] = $this->language->get('heading_title');
     $this->data['text_login'] = $this->language->get('text_login');
     $this->data['text_forgotten'] = $this->language->get('text_forgotten');
     $this->data['entry_username'] = $this->language->get('entry_username');
     $this->data['entry_password'] = $this->language->get('entry_password');
     $this->data['button_login'] = $this->language->get('button_login');
     if (isset($this->session->data['token']) && !isset($this->request->get['token']) || isset($this->request->get['token']) && (isset($this->session->data['token']) && $this->request->get['token'] != $this->session->data['token'])) {
         $this->error['warning'] = $this->language->get('error_token');
     }
     if (isset($this->error['warning'])) {
         $this->data['error_warning'] = $this->error['warning'];
     } else {
         $this->data['error_warning'] = '';
     }
     if (isset($this->session->data['success'])) {
         $this->data['success'] = $this->session->data['success'];
         unset($this->session->data['success']);
     } else {
         $this->data['success'] = '';
     }
     $this->data['action'] = $this->url->link('common/login', '', 'SSL');
     if (isset($this->request->post['username'])) {
         $this->data['username'] = $this->request->post['username'];
     } else {
         $this->data['username'] = '';
     }
     if (isset($this->request->post['password'])) {
         $this->data['password'] = $this->request->post['password'];
     } else {
         $this->data['password'] = '';
     }
     if (isset($this->request->get['route'])) {
         $route = $this->request->get['route'];
         unset($this->request->get['route']);
         if (isset($this->request->get['token'])) {
             unset($this->request->get['token']);
         }
         $url = '';
         if ($this->request->get) {
             $url .= http_build_query($this->request->get);
         }
         $this->data['redirect'] = $this->url->link($route, $url, 'SSL');
     } else {
         $this->data['redirect'] = '';
     }
     if ($this->config->get('config_password')) {
         $this->data['forgotten'] = $this->url->link('common/forgotten', '', 'SSL');
     } else {
         $this->data['forgotten'] = '';
     }
     $this->template = 'common/login.tpl';
     $this->children = array('common/header', 'common/footer');
     $this->response->setOutput($this->render());
 }
开发者ID:xanderwp,项目名称:opencart-ce,代码行数:69,代码来源:login.php

示例8: editPassword

 public function editPassword($email, $password)
 {
     $this->db->query("UPDATE " . DB_PREFIX . "customer SET salt = '" . $this->db->escape($salt = substr(hash_rand('md5'), 0, 9)) . "', password = '" . $this->db->escape(sha1($salt . sha1($salt . sha1($password)))) . "' WHERE LOWER(email) = '" . $this->db->escape(utf8_strtolower($email)) . "'");
 }
开发者ID:skyosev,项目名称:OpenCart-Overclocked,代码行数:4,代码来源:customer.php

示例9: index

 public function index()
 {
     if ($this->affiliate->isLogged()) {
         $this->redirect($this->url->link('affiliate/account', '', 'SSL'));
     }
     if ($this->config->get('config_secure') && !$this->request->isSecure()) {
         $this->redirect($this->url->link('affiliate/forgotten', '', 'SSL'), 301);
     }
     $this->language->load('affiliate/forgotten');
     $this->document->setTitle($this->language->get('heading_title'));
     $this->load->model('affiliate/affiliate');
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate()) {
         $this->language->load('mail/forgotten');
         $password = substr(hash_rand('md5'), 0, 10);
         $this->model_affiliate_affiliate->editPassword($this->request->post['email'], $password);
         $subject = sprintf($this->language->get('text_subject'), $this->config->get('config_name'));
         $message = sprintf($this->language->get('text_greeting'), $this->config->get('config_name')) . "\n\n";
         $message .= $this->language->get('text_password') . "\n\n";
         $message .= $password;
         $mail = new Mail();
         $mail->protocol = $this->config->get('config_mail_protocol');
         $mail->parameter = $this->config->get('config_mail_parameter');
         $mail->hostname = $this->config->get('config_smtp_host');
         $mail->username = $this->config->get('config_smtp_username');
         $mail->password = $this->config->get('config_smtp_password');
         $mail->port = $this->config->get('config_smtp_port');
         $mail->timeout = $this->config->get('config_smtp_timeout');
         $mail->setTo($this->request->post['email']);
         $mail->setFrom($this->config->get('config_email'));
         $mail->setSender($this->config->get('config_name'));
         $mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'));
         $mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
         $mail->send();
         $this->session->data['success'] = $this->language->get('text_success');
         $this->redirect($this->url->link('affiliate/login', '', 'SSL'));
     }
     $this->data['breadcrumbs'] = array();
     $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home'), 'separator' => false);
     $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_account'), 'href' => $this->url->link('affiliate/account', '', 'SSL'), 'separator' => $this->language->get('text_separator'));
     $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_forgotten'), 'href' => $this->url->link('affiliate/forgotten', '', 'SSL'), 'separator' => $this->language->get('text_separator'));
     $this->data['heading_title'] = $this->language->get('heading_title');
     $this->data['text_your_email'] = $this->language->get('text_your_email');
     $this->data['text_email'] = $this->language->get('text_email');
     $this->data['entry_email'] = $this->language->get('entry_email');
     $this->data['button_continue'] = $this->language->get('button_continue');
     $this->data['button_back'] = $this->language->get('button_back');
     if (isset($this->error['warning'])) {
         $this->data['error_warning'] = $this->error['warning'];
     } else {
         $this->data['error_warning'] = '';
     }
     $this->data['action'] = $this->url->link('affiliate/forgotten', '', 'SSL');
     $this->data['back'] = $this->url->link('affiliate/login', '', 'SSL');
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/affiliate/forgotten.tpl')) {
         $this->template = $this->config->get('config_template') . '/template/affiliate/forgotten.tpl';
     } else {
         $this->template = 'default/template/affiliate/forgotten.tpl';
     }
     $this->children = array('common/column_left', 'common/column_right', 'common/content_top', 'common/content_bottom', 'common/footer', 'common/header');
     $this->response->setOutput($this->render());
 }
开发者ID:xanderwp,项目名称:opencart-ce,代码行数:61,代码来源:forgotten.php

示例10: upload

 public function upload()
 {
     $this->language->load('catalog/download');
     $json = array();
     if (!$this->user->hasPermission('modify', 'catalog/download')) {
         $json['error'] = $this->language->get('error_permission');
     }
     if (!isset($json['error'])) {
         if (!empty($this->request->files['file']['name'])) {
             $filename = basename(html_entity_decode($this->request->files['file']['name'], ENT_QUOTES, 'UTF-8'));
             if (utf8_strlen($filename) < 3 || utf8_strlen($filename) > 128) {
                 $json['error'] = $this->language->get('error_filename');
             }
             // Allowed file extension types
             $allowed = array();
             $filetypes = explode("\n", str_replace(array("\r\n", "\r"), "\n", $this->config->get('config_file_extension_allowed')));
             foreach ($filetypes as $filetype) {
                 $allowed[] = trim($filetype);
             }
             if (!in_array(substr(strrchr($filename, '.'), 1), $allowed)) {
                 $json['error'] = $this->language->get('error_filetype');
             }
             // Allowed file mime types
             $allowed = array();
             $filetypes = explode("\n", str_replace(array("\r\n", "\r"), "\n", $this->config->get('config_file_mime_allowed')));
             foreach ($filetypes as $filetype) {
                 $allowed[] = trim($filetype);
             }
             if (!in_array($this->request->files['file']['type'], $allowed)) {
                 $json['error'] = $this->language->get('error_filetype');
             }
             // Check to see if any PHP files are trying to be uploaded
             $content = file_get_contents($this->request->files['file']['tmp_name']);
             if (preg_match('/\\<\\?php/i', $content)) {
                 $json['error'] = $this->language->get('error_filetype');
             }
             if ($this->request->files['file']['error'] != UPLOAD_ERR_OK) {
                 $json['error'] = $this->language->get('error_upload_' . $this->request->files['file']['error']);
             }
         } else {
             $json['error'] = $this->language->get('error_upload');
         }
     }
     if (!isset($json['error'])) {
         if (is_uploaded_file($this->request->files['file']['tmp_name']) && file_exists($this->request->files['file']['tmp_name'])) {
             $ext = hash_rand('md5');
             $json['filename'] = $filename . '.' . $ext;
             $json['mask'] = $filename;
             move_uploaded_file($this->request->files['file']['tmp_name'], DIR_DOWNLOAD . $filename . '.' . $ext);
         }
         $json['success'] = $this->language->get('text_upload');
     }
     $this->response->setOutput(json_encode($json));
 }
开发者ID:packetlost,项目名称:OpenCart-Overclocked,代码行数:54,代码来源:download.php

示例11: upload

 public function upload()
 {
     $this->language->load('sale/order');
     $json = array();
     if ($this->request->server['REQUEST_METHOD'] == 'POST') {
         if (!empty($this->request->files['file']['name'])) {
             $filename = html_entity_decode($this->request->files['file']['name'], ENT_QUOTES, 'UTF-8');
             if (utf8_strlen($filename) < 3 || utf8_strlen($filename) > 128) {
                 $json['error'] = $this->language->get('error_filename');
             }
             // Allowed file extension types
             $allowed = array();
             $filetypes = explode("\n", str_replace(array("\r\n", "\r"), "\n", $this->config->get('config_file_extension_allowed')));
             foreach ($filetypes as $filetype) {
                 $allowed[] = trim($filetype);
             }
             if (!in_array(substr(strrchr($filename, '.'), 1), $allowed)) {
                 $json['error'] = $this->language->get('error_filetype');
             }
             // Allowed file mime types
             $allowed = array();
             $filetypes = explode("\n", str_replace(array("\r\n", "\r"), "\n", $this->config->get('config_file_mime_allowed')));
             foreach ($filetypes as $filetype) {
                 $allowed[] = trim($filetype);
             }
             if (!in_array($this->request->files['file']['type'], $allowed)) {
                 $json['error'] = $this->language->get('error_filetype');
             }
             if ($this->request->files['file']['error'] != UPLOAD_ERR_OK) {
                 $json['error'] = $this->language->get('error_upload_' . $this->request->files['file']['error']);
             }
         } else {
             $json['error'] = $this->language->get('error_upload');
         }
         if (!isset($json['error'])) {
             if (is_uploaded_file($this->request->files['file']['tmp_name']) && file_exists($this->request->files['file']['tmp_name'])) {
                 $file = basename($filename) . '.' . hash_rand('md5');
                 $json['file'] = $file;
                 move_uploaded_file($this->request->files['file']['tmp_name'], DIR_DOWNLOAD . $file);
             }
             $json['success'] = $this->language->get('text_upload');
         }
     }
     $this->response->setOutput(json_encode($json));
 }
开发者ID:xanderwp,项目名称:opencart-ce,代码行数:45,代码来源:order.php

示例12: index


//.........这里部分代码省略.........
         } else {
             $data['shipping_firstname'] = '';
             $data['shipping_lastname'] = '';
             $data['shipping_company'] = '';
             $data['shipping_address_1'] = '';
             $data['shipping_address_2'] = '';
             $data['shipping_city'] = '';
             $data['shipping_postcode'] = '';
             $data['shipping_zone'] = '';
             $data['shipping_zone_id'] = '';
             $data['shipping_country'] = '';
             $data['shipping_country_id'] = '';
             $data['shipping_address_format'] = '';
             $data['shipping_method'] = '';
             $data['shipping_code'] = '';
         }
         $product_data = array();
         foreach ($this->cart->getProducts() as $product) {
             $option_data = array();
             foreach ($product['option'] as $option) {
                 if ($option['type'] != 'file') {
                     $value = $option['option_value'];
                 } else {
                     $value = $this->encryption->decrypt($option['option_value']);
                 }
                 $option_data[] = array('product_option_id' => $option['product_option_id'], 'product_option_value_id' => $option['product_option_value_id'], 'option_id' => $option['option_id'], 'option_value_id' => $option['option_value_id'], 'name' => $option['name'], 'value' => $value, 'type' => $option['type']);
             }
             $product_data[] = array('product_id' => $product['product_id'], 'name' => $product['name'], 'model' => $product['model'], 'option' => $option_data, 'download' => $product['download'], 'quantity' => $product['quantity'], 'subtract' => $product['subtract'], 'price' => $product['price'], 'cost' => $product['cost'], 'total' => $product['total'], 'tax' => $this->tax->getTax($product['price'], $product['tax_class_id']), 'reward' => $product['reward']);
         }
         // Gift Voucher
         $voucher_data = array();
         if (!empty($this->session->data['vouchers'])) {
             foreach ($this->session->data['vouchers'] as $voucher) {
                 $voucher_data[] = array('description' => $voucher['description'], 'code' => substr(hash_rand('md5'), 0, 10), 'to_name' => $voucher['to_name'], 'to_email' => $voucher['to_email'], 'from_name' => $voucher['from_name'], 'from_email' => $voucher['from_email'], 'voucher_theme_id' => $voucher['voucher_theme_id'], 'message' => $voucher['message'], 'amount' => $voucher['amount']);
             }
         }
         $data['products'] = $product_data;
         $data['vouchers'] = $voucher_data;
         $data['totals'] = $total_data;
         $data['comment'] = $this->session->data['comment'];
         $data['total'] = $total;
         if (isset($this->request->cookie['tracking'])) {
             $this->load->model('affiliate/affiliate');
             $affiliate_info = $this->model_affiliate_affiliate->getAffiliateByCode($this->request->cookie['tracking']);
             $subtotal = $this->cart->getSubTotal();
             if ($affiliate_info) {
                 $data['affiliate_id'] = $affiliate_info['affiliate_id'];
                 $data['commission'] = $subtotal / 100 * $affiliate_info['commission'];
             } else {
                 $data['affiliate_id'] = 0;
                 $data['commission'] = 0;
             }
         } else {
             $data['affiliate_id'] = 0;
             $data['commission'] = 0;
         }
         $data['language_id'] = $this->config->get('config_language_id');
         $data['currency_id'] = $this->currency->getId();
         $data['currency_code'] = $this->currency->getCode();
         $data['currency_value'] = $this->currency->getValue($this->currency->getCode());
         $data['ip'] = $this->request->server['REMOTE_ADDR'];
         if (!empty($this->request->server['HTTP_X_FORWARDED_FOR'])) {
             $data['forwarded_ip'] = $this->request->server['HTTP_X_FORWARDED_FOR'];
         } elseif (!empty($this->request->server['HTTP_CLIENT_IP'])) {
             $data['forwarded_ip'] = $this->request->server['HTTP_CLIENT_IP'];
         } else {
开发者ID:packetlost,项目名称:OpenCart-Overclocked,代码行数:67,代码来源:confirm.php

示例13: index

 public function index()
 {
     $this->language->load('payment/paymate');
     $this->document->setTitle($this->language->get('heading_title'));
     $this->load->model('setting/setting');
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate()) {
         $this->model_setting_setting->editSetting('paymate', $this->request->post);
         $this->session->data['success'] = $this->language->get('text_success');
         $this->redirect($this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL'));
     }
     $this->data['heading_title'] = $this->language->get('heading_title');
     $this->data['text_enabled'] = $this->language->get('text_enabled');
     $this->data['text_disabled'] = $this->language->get('text_disabled');
     $this->data['text_all_zones'] = $this->language->get('text_all_zones');
     $this->data['text_yes'] = $this->language->get('text_yes');
     $this->data['text_no'] = $this->language->get('text_no');
     $this->data['entry_username'] = $this->language->get('entry_username');
     $this->data['entry_password'] = $this->language->get('entry_password');
     $this->data['entry_test'] = $this->language->get('entry_test');
     $this->data['entry_total'] = $this->language->get('entry_total');
     $this->data['entry_order_status'] = $this->language->get('entry_order_status');
     $this->data['entry_geo_zone'] = $this->language->get('entry_geo_zone');
     $this->data['entry_status'] = $this->language->get('entry_status');
     $this->data['entry_sort_order'] = $this->language->get('entry_sort_order');
     $this->data['button_save'] = $this->language->get('button_save');
     $this->data['button_cancel'] = $this->language->get('button_cancel');
     if (isset($this->error['warning'])) {
         $this->data['error_warning'] = $this->error['warning'];
     } else {
         $this->data['error_warning'] = '';
     }
     if (isset($this->error['username'])) {
         $this->data['error_username'] = $this->error['username'];
     } else {
         $this->data['error_username'] = '';
     }
     if (isset($this->error['password'])) {
         $this->data['error_password'] = $this->error['password'];
     } else {
         $this->data['error_password'] = '';
     }
     $this->data['breadcrumbs'] = array();
     $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'), 'separator' => false);
     $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_payment'), 'href' => $this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL'), 'separator' => ' :: ');
     $this->data['breadcrumbs'][] = array('text' => $this->language->get('heading_title'), 'href' => $this->url->link('payment/paymate', 'token=' . $this->session->data['token'], 'SSL'), 'separator' => ' :: ');
     $this->data['action'] = $this->url->link('payment/paymate', 'token=' . $this->session->data['token'], 'SSL');
     $this->data['cancel'] = $this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL');
     if (isset($this->request->post['paymate_username'])) {
         $this->data['paymate_username'] = $this->request->post['paymate_username'];
     } else {
         $this->data['paymate_username'] = $this->config->get('paymate_username');
     }
     if (isset($this->request->post['paymate_password'])) {
         $this->data['paymate_username'] = $this->request->post['paymate_username'];
     } elseif ($this->config->get('paymate_password')) {
         $this->data['paymate_password'] = $this->config->get('paymate_password');
     } else {
         $this->data['paymate_password'] = hash_rand('md5');
     }
     if (isset($this->request->post['paymate_test'])) {
         $this->data['paymate_test'] = $this->request->post['paymate_test'];
     } else {
         $this->data['paymate_test'] = $this->config->get('paymate_test');
     }
     if (isset($this->request->post['paymate_total'])) {
         $this->data['paymate_total'] = $this->request->post['paymate_total'];
     } else {
         $this->data['paymate_total'] = $this->config->get('paymate_total');
     }
     if (isset($this->request->post['paymate_order_status_id'])) {
         $this->data['paymate_order_status_id'] = $this->request->post['paymate_order_status_id'];
     } else {
         $this->data['paymate_order_status_id'] = $this->config->get('paymate_order_status_id');
     }
     $this->load->model('localisation/order_status');
     $this->data['order_statuses'] = $this->model_localisation_order_status->getOrderStatuses();
     if (isset($this->request->post['paymate_geo_zone_id'])) {
         $this->data['paymate_geo_zone_id'] = $this->request->post['paymate_geo_zone_id'];
     } else {
         $this->data['paymate_geo_zone_id'] = $this->config->get('paymate_geo_zone_id');
     }
     $this->load->model('localisation/geo_zone');
     $this->data['geo_zones'] = $this->model_localisation_geo_zone->getGeoZones();
     if (isset($this->request->post['paymate_status'])) {
         $this->data['paymate_status'] = $this->request->post['paymate_status'];
     } else {
         $this->data['paymate_status'] = $this->config->get('paymate_status');
     }
     if (isset($this->request->post['paymate_sort_order'])) {
         $this->data['paymate_sort_order'] = $this->request->post['paymate_sort_order'];
     } else {
         $this->data['paymate_sort_order'] = $this->config->get('paymate_sort_order');
     }
     $this->template = 'payment/paymate.tpl';
     $this->children = array('common/header', 'common/footer');
     $this->response->setOutput($this->render());
 }
开发者ID:xanderwp,项目名称:opencart-ce,代码行数:97,代码来源:paymate.php

示例14: setToken

 public function setToken()
 {
     $this->session->data['customer_token'] = hash_rand('md5');
 }
开发者ID:xanderwp,项目名称:opencart-ce,代码行数:4,代码来源:customer.php

示例15: index


//.........这里部分代码省略.........
             $this->tax->setShippingAddress($this->request->post['shipping_country_id'], $this->request->post['shipping_zone_id']);
         } else {
             $this->tax->setShippingAddress($this->config->get('config_country_id'), $this->config->get('config_zone_id'));
         }
         $this->tax->setPaymentAddress($this->request->post['payment_country_id'], $this->request->post['payment_zone_id']);
         $this->tax->setStoreAddress($this->config->get('config_country_id'), $this->config->get('config_zone_id'));
         // Products
         $json['order_product'] = array();
         $products = $this->cart->getProducts();
         foreach ($products as $product) {
             $product_total = 0;
             foreach ($products as $product_2) {
                 if ($product_2['product_id'] == $product['product_id']) {
                     $product_total += $product_2['quantity'];
                 }
             }
             if ($product['minimum'] > $product_total) {
                 $json['error']['product']['minimum'][] = sprintf($this->language->get('error_minimum'), $product['name'], $product['minimum']);
             }
             $option_data = array();
             foreach ($product['option'] as $option) {
                 $option_data[] = array('product_option_id' => $option['product_option_id'], 'product_option_value_id' => $option['product_option_value_id'], 'name' => $option['name'], 'value' => $option['option_value'], 'type' => $option['type']);
             }
             $download_data = array();
             foreach ($product['download'] as $download) {
                 $download_data[] = array('name' => $download['name'], 'filename' => $download['filename'], 'mask' => $download['mask'], 'remaining' => $download['remaining']);
             }
             $json['order_product'][] = array('product_id' => $product['product_id'], 'name' => $product['name'], 'model' => $product['model'], 'option' => $option_data, 'download' => $download_data, 'quantity' => $product['quantity'], 'stock' => $product['stock'], 'price' => $product['price'], 'total' => $product['total'], 'tax' => $this->tax->getTax($product['price'], $product['tax_class_id']), 'reward' => $product['reward']);
         }
         // Voucher
         $this->session->data['vouchers'] = array();
         if (isset($this->request->post['order_voucher'])) {
             foreach ($this->request->post['order_voucher'] as $voucher) {
                 $this->session->data['vouchers'][] = array('voucher_id' => $voucher['voucher_id'], 'description' => $voucher['description'], 'code' => substr(hash_rand('md5'), 0, 10), 'from_name' => $voucher['from_name'], 'from_email' => $voucher['from_email'], 'to_name' => $voucher['to_name'], 'to_email' => $voucher['to_email'], 'voucher_theme_id' => $voucher['voucher_theme_id'], 'message' => $voucher['message'], 'amount' => $voucher['amount']);
             }
         }
         // Add a new voucher if set
         if (isset($this->request->post['from_name']) && isset($this->request->post['from_email']) && isset($this->request->post['to_name']) && isset($this->request->post['to_email']) && isset($this->request->post['amount'])) {
             if (utf8_strlen($this->request->post['from_name']) < 1 || utf8_strlen($this->request->post['from_name']) > 64) {
                 $json['error']['vouchers']['from_name'] = $this->language->get('error_from_name');
             }
             if (utf8_strlen($this->request->post['from_email']) > 96 || !preg_match('/^[^\\@]+@.*.[a-z]{2,15}$/i', $this->request->post['from_email'])) {
                 $json['error']['vouchers']['from_email'] = $this->language->get('error_email');
             }
             if (utf8_strlen($this->request->post['to_name']) < 1 || utf8_strlen($this->request->post['to_name']) > 64) {
                 $json['error']['vouchers']['to_name'] = $this->language->get('error_to_name');
             }
             if (utf8_strlen($this->request->post['to_email']) > 96 || !preg_match('/^[^\\@]+@.*.[a-z]{2,15}$/i', $this->request->post['to_email'])) {
                 $json['error']['vouchers']['to_email'] = $this->language->get('error_email');
             }
             if ($this->request->post['amount'] < $this->config->get('config_voucher_min') || $this->request->post['amount'] > $this->config->get('config_voucher_max')) {
                 $json['error']['vouchers']['amount'] = sprintf($this->language->get('error_amount'), $this->currency->format($this->config->get('config_voucher_min'), false, 1), $this->currency->format($this->config->get('config_voucher_max'), false, 1) . ' ' . $this->config->get('config_currency'));
             }
             if (!isset($json['error']['vouchers'])) {
                 $voucher_data = array('order_id' => 0, 'code' => substr(hash_rand('md5'), 0, 10), 'from_name' => $this->request->post['from_name'], 'from_email' => $this->request->post['from_email'], 'to_name' => $this->request->post['to_name'], 'to_email' => $this->request->post['to_email'], 'voucher_theme_id' => $this->request->post['voucher_theme_id'], 'message' => $this->request->post['message'], 'amount' => $this->request->post['amount'], 'status' => true);
                 $this->load->model('checkout/voucher');
                 $voucher_id = $this->model_checkout_voucher->addVoucher(0, $voucher_data);
                 $this->session->data['vouchers'][] = array('voucher_id' => $voucher_id, 'description' => sprintf($this->language->get('text_for'), $this->currency->format($this->request->post['amount'], $this->config->get('config_currency')), $this->request->post['to_name']), 'code' => substr(hash_rand('md5'), 0, 10), 'from_name' => $this->request->post['from_name'], 'from_email' => $this->request->post['from_email'], 'to_name' => $this->request->post['to_name'], 'to_email' => $this->request->post['to_email'], 'voucher_theme_id' => $this->request->post['voucher_theme_id'], 'message' => $this->request->post['message'], 'amount' => $this->request->post['amount']);
             }
         }
         $json['order_voucher'] = array();
         foreach ($this->session->data['vouchers'] as $voucher) {
             $json['order_voucher'][] = array('voucher_id' => $voucher['voucher_id'], 'description' => $voucher['description'], 'code' => $voucher['code'], 'from_name' => $voucher['from_name'], 'from_email' => $voucher['from_email'], 'to_name' => $voucher['to_name'], 'to_email' => $voucher['to_email'], 'voucher_theme_id' => $voucher['voucher_theme_id'], 'message' => $voucher['message'], 'amount' => $voucher['amount']);
         }
         $this->load->model('setting/extension');
         $this->load->model('localisation/country');
开发者ID:ahmatjan,项目名称:OpenCart-Overclocked,代码行数:67,代码来源:manual.php


注:本文中的hash_rand函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。