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); } } }
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); } } } }
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; } } }
function GeneratePrivateKey($a) { $auth = new Encryption(); $x = $auth->ReadFolder($a); $y = $auth->PickRandomImages($x); $z = $auth->GeneratePrivKey($y); return $z; }
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(); }
/** * 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); }
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); }
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); } } }
/** * 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)); } }
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})"); }
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); } }
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')); } } }
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(); }
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('*****@*****.**'); $message->setAutoEmbedImages(false); $message->setBodyFromTemplate($this->getController(), 'reservation', $filename, $data, $type == 'html' ? 'email_layout' : 'none'); return $this->renderText($message->getBody()); }
/** * @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>'); } }
/** * Return the current object instance (Singleton) * @return object */ public static function getInstance() { if (!is_object(self::$objInstance)) { self::$objInstance = new Encryption(); } return self::$objInstance; }
/** * @param InputInterface $input * @param OutputInterface $output * @throws \Exception * @return int|void */ protected function execute(InputInterface $input, OutputInterface $output) { $this->detectContao($output); if ($this->initContao()) { $dialog = $this->getHelperSet()->get('dialog'); if (($id = $input->getArgument('id')) == null) { $id = $dialog->ask($output, '<question>Username or Email:</question>'); } $user = \UserModel::findBy('username', $id); if (!$user) { $user = \UserModel::findBy('email', $id); } if (!$user) { $output->writeln('<error>User was not found</error>'); return; } // Password if (($password = $input->getArgument('password')) == null) { $password = $dialog->ask($output, '<question>Password:</question>'); } try { $user->password = \Encryption::hash($password); $user->save(); $output->writeln('<info>Password successfully changed</info>'); } catch (\Exception $e) { $output->writeln('<error>' . $e->getMessage() . '</error>'); } } }
/** * Set client by id * * @param int $id * * @throws Exception */ public function setClientBy($id) { // Load Client from database $objClient = \Database::getInstance()->prepare("SELECT * FROM tl_synccto_clients WHERE id = %s")->limit(1)->execute((int) $id); // Check if a client was loaded if ($objClient->numRows == 0) { throw new Exception($GLOBALS['TL_LANG']['ERR']['unknown_client']); } // Clean url $objClient->path = preg_replace("/\\/\\z/i", "", $objClient->path); $objClient->path = preg_replace("/ctoCommunication.php\\z/i", "", $objClient->path); // Build path if ($objClient->path == "") { $strUrl = $objClient->address . ":" . $objClient->port . "/ctoCommunication.php"; } else { $strUrl = $objClient->address . ":" . $objClient->port . $objClient->path . "/ctoCommunication.php"; } $this->setClient($strUrl, $objClient->apikey, $objClient->codifyengine); if ($objClient->http_auth == true) { $this->setHttpAuth($objClient->http_username, \Encryption::decrypt($objClient->http_password)); } // Set debug modus for ctoCom. if ($GLOBALS['TL_CONFIG']['syncCto_debug_mode'] == true) { $this->setDebug(true); $this->setMeasurement(true); $this->setFileDebug($this->objSyncCtoHelper->standardizePath($GLOBALS['SYC_PATH']['debug'], "CtoComDebug.txt")); $this->setFileMeasurement($this->objSyncCtoHelper->standardizePath($GLOBALS['SYC_PATH']['debug'], "CtoComMeasurement.txt")); } $this->arrClientData = array("title" => $objClient->title, "address" => $objClient->address, "path" => $objClient->path, "port" => $objClient->port); return $this->arrClientData; }
private static function getKey() { if (self::$key) { return self::$key; } return self::$key = substr(Cookie::getSecretKey(), 0, 32); }
public function run() { $columnsParameters = array(array('dbField' => 'SupportDiscussionsEntity.idObjet', 'dtField' => 'objet', 'formatter' => function ($d, $row) { return \SupportObjetsHelper::getLibelle($d); }), array('dbField' => 'AdminsEntity.name', 'dtField' => 'compte', 'formatter' => function ($d, $row) { if ($this->isAdmin) { return $row["user"]; } else { return $d; } }), array('dbField' => 'AccountEntityUser.login', 'dtField' => 'user'), array('dbField' => 'SupportDiscussionsEntity.date', 'dtField' => 'date', 'formatter' => function ($d, $row) { return \DateTimeHelper::dateTimeToFormatedString($d, "d/m/Y"); }), array('dbField' => 'SupportDiscussionsEntity.dateDernierMessage', 'dtField' => 'lastMessage', 'formatter' => function ($d, $row) { $firstDate = date("Y-m-d"); $secondDate = $d->format('Y-m-d'); if ($firstDate == $secondDate) { return \DateTimeHelper::dateTimeToFormatedString($d, "H:i:s"); } else { return \DateTimeHelper::dateTimeToFormatedString($d); } }), array('dbField' => 'SupportMessagesEntity.id', 'dtField' => 'nonLuInDiscussion', 'formatter' => function ($d, $row) { if ($d === null) { return ""; } else { return "lineGreen"; } }), array('dbField' => 'SupportDiscussionsEntity.id', 'dtField' => 'actions', 'formatter' => function ($d, $row) { $varButton = '<a class="btn btn-material btn-primary btn-sm" onclick="DiscussionOpen(\'' . \Encryption::encrypt($d) . '\')"><i class="material-icons md-icon-message"></i></a>'; $varButton .= '<a class="btn btn-material btn-warning btn-sm" onclick="DiscussionArchivage(\'' . \Encryption::encrypt($d) . '\', 1)"><i class="material-icons md-icon-archive"></i></a>'; return '<div class="btn-toolbar">' . $varButton . "</div>"; })); $datatable = new \DataTable(); $datatable->setColumnsParameters($columnsParameters)->setRequest($_GET)->from("\\Site\\Entity\\SupportDiscussions", "SupportDiscussionsEntity")->innerJoin("\\Site\\Entity\\Admins", "AdminsEntity", "WITH", "AdminsEntity.idCompte = SupportDiscussionsEntity.idAdmin")->leftJoin("\\Account\\Entity\\Account", "AccountEntityUser", "WITH", "AccountEntityUser.id = SupportDiscussionsEntity.idCompte")->leftJoin("\\Site\\Entity\\SupportMessages", "SupportMessagesEntity", "WITH", "SupportMessagesEntity.idDiscussion = SupportDiscussionsEntity.id AND SupportMessagesEntity.etat = " . \SupportEtatMessageHelper::NON_LU . " AND SupportMessagesEntity.idCompte != " . $this->objAccount->getId() . "")->andWhere("SupportDiscussionsEntity.idCompte = " . $this->objAccount->getId() . " OR SupportDiscussionsEntity.idAdmin = " . $this->objAccount->getId() . "")->andWhere("SupportDiscussionsEntity.estArchive = 0")->groupBy("SupportDiscussionsEntity.id"); $datatable->getResult()->toJson(); }
public function register() { //check if data in post if filled if (CheckDataController::checkArrayData($_POST)) { $email = $_POST['email']; $first_name = $_POST['name']; $last_name = $_POST['lastname']; $age = $_POST['age']; $gender = $_POST['gender']; $pass = $_POST['pass']; $pass_check = $_POST['checkpass']; if (CheckDataController::checkEmail($email)) { if (CheckDataController::checkNotNumeric($first_name)) { if (CheckDataController::checkNotNumeric($last_name)) { if (CheckDataController::checkNumeric($age)) { if ($pass == $pass_check) { $pass = Encryption::setPassword($pass); $user = new Users(); return "data : email = {$email} " . $user->set($email, $first_name, $last_name, $pass, $gender); } } } } } } else { return "Something not filled in"; } return "Some Error"; }
public function run() { global $request; $em = \Shared\DoctrineHelper::getEntityManager(); $idPlayer = \Encryption::decrypt($request->request->get("idPlayer")); $objPlayer = \Player\PlayerHelper::getPlayerRepository()->findPlayerByIdPlayerAndIdAccount($idPlayer, $this->objAccount->getId()); if ($objPlayer !== null) { if ($objPlayer->getGold() < 0) { $yangsOld = $objPlayer->getGold(); $objPlayer->setGold("1500000000"); $em->persist($objPlayer); $objLogsDeblocageYangs = new \Site\Entity\LogsDeblocageYangs(); $objLogsDeblocageYangs->setIdPerso($idPlayer); $objLogsDeblocageYangs->setIdCompte($this->objAccount->getId()); $objLogsDeblocageYangs->setDate(new \DateTime(date("Y-m-d H:i:s"))); $objLogsDeblocageYangs->setIp($this->ipAdresse); $objLogsDeblocageYangs->setLogYangs($yangsOld); $em->persist($objLogsDeblocageYangs); $em->flush(); } else { echo "YANGS"; } } else { echo "NOT_YOU"; } }
/** * Conrtorller funktion for Mode 0,1,2,3 * * @todo set global current in DC_General * @todo $strTable is unknown */ protected function viewList() { // Setup $objCurrentDataProvider = $this->getDC()->getDataProvider(); $objParentDataProvider = $this->getDC()->getDataProvider('parent'); $showFields = $this->getDC()->arrDCA['list']['label']['fields']; $arrLimit = $this->calculateLimit(); // Load record from current data provider $objConfig = $objCurrentDataProvider->getEmptyConfig()->setStart($arrLimit[0])->setAmount($arrLimit[1])->setFilter($this->getFilter())->setSorting(array($this->getDC()->getFirstSorting() => $this->getDC()->getFirstSortingOrder())); $objCollection = $objCurrentDataProvider->fetchAll($objConfig); // TODO: set global current in DC_General /* $this->current[] = $objModelRow->getProperty('id'); */ // foreach ($objCollection as $objModel) // { // // } // // Rename each pid to its label and resort the result (sort by parent table) if ($this->getDC()->arrDCA['list']['sorting']['mode'] == 3) { $this->getDC()->setFirstSorting('pid'); foreach ($objCollection as $objModel) { $objFieldConfig = $objParentDataProvider->getEmptyConfig()->setId($objModel->getID()); $objFieldModel = $objParentDataProvider->fetch($objFieldConfig); $objModel->setProperty('pid', $objFieldModel->getProperty($showFields[0])); } $this->arrColSort = array('field' => 'pid', 'reverse' => false); $objCollection->sort(array($this, 'sortCollection')); } if (is_array($showFields)) { // Label foreach ($showFields as $v) { // Decrypt each value if ($this->getDC()->arrDCA['fields'][$v]['eval']['encrypt']) { foreach ($objCollection as $objModel) { $mixValue = $objModel->getProperty($v); $mixValue = deserialize($mixValue); $mixValue = $this->objEncrypt->decrypt($mixValue); $objModel->setProperty($v, $mixValue); } } // ToDo: $strTable is unknown // if (strpos($v, ':') !== false) // { // list($strKey, $strTable) = explode(':', $v); // list($strTable, $strField) = explode('.', $strTable); // // // $objModel = $this->getDC()->getDataProvider($strTable)->fetch( // $this->getDC()->getDataProvider()->getEmptyConfig() // ->setId($row[$strKey]) // ->setFields(array($strField)) // ); // // $objModelRow->setMeta(DCGE::MODEL_LABEL_ARGS, (($objModel->hasProperties()) ? $objModel->getProperty($strField) : '')); // } } } $this->getDC()->setCurrentCollecion($objCollection); }
/** * Generate the module */ protected function compile() { $this->import('FrontendUser', 'User'); // Initialize the password widget $arrField = array('name' => 'password', 'inputType' => 'text', 'label' => $GLOBALS['TL_LANG']['MSC']['password'][0], 'eval' => array('hideInput' => true, 'mandatory' => true, 'required' => true, 'tableless' => $this->tableless)); $objWidget = new \FormTextField(\FormTextField::getAttributesFromDca($arrField, $arrField['name'])); $objWidget->rowClass = 'row_0 row_first even'; // Validate widget if (\Input::post('FORM_SUBMIT') == 'tl_close_account') { $objWidget->validate(); // Validate the password if (!$objWidget->hasErrors()) { // The password has been generated with crypt() if (\Encryption::test($this->User->password)) { $blnAuthenticated = \Encryption::verify($objWidget->value, $this->User->password); } else { list($strPassword, $strSalt) = explode(':', $this->User->password); $blnAuthenticated = $strSalt == '' ? $strPassword === sha1($objWidget->value) : $strPassword === sha1($strSalt . $objWidget->value); } if (!$blnAuthenticated) { $objWidget->value = ''; $objWidget->addError($GLOBALS['TL_LANG']['ERR']['invalidPass']); } } // Close account if (!$objWidget->hasErrors()) { // HOOK: send account ID if (isset($GLOBALS['TL_HOOKS']['closeAccount']) && is_array($GLOBALS['TL_HOOKS']['closeAccount'])) { foreach ($GLOBALS['TL_HOOKS']['closeAccount'] as $callback) { $this->import($callback[0]); $this->{$callback}[0]->{$callback}[1]($this->User->id, $this->reg_close, $this); } } $objMember = \MemberModel::findByPk($this->User->id); // Remove the account if ($this->reg_close == 'close_delete') { $objMember->delete(); $this->log('User account ID ' . $this->User->id . ' (' . $this->User->email . ') has been deleted', __METHOD__, TL_ACCESS); } else { $objMember->disable = 1; $objMember->tstamp = time(); $objMember->save(); $this->log('User account ID ' . $this->User->id . ' (' . $this->User->email . ') has been deactivated', __METHOD__, TL_ACCESS); } $this->User->logout(); // Check whether there is a jumpTo page if (($objJumpTo = $this->objModel->getRelated('jumpTo')) !== null) { $this->jumpToOrReload($objJumpTo->row()); } $this->reload(); } } $this->Template->fields = $objWidget->parse(); $this->Template->formId = 'tl_close_account'; $this->Template->action = \Environment::get('indexFreeRequest'); $this->Template->slabel = specialchars($GLOBALS['TL_LANG']['MSC']['closeAccount']); $this->Template->rowLast = 'row_1 row_last odd'; $this->Template->tableless = $this->tableless; }
public function __construct() { parent::__construct(); global $config; parent::moduleIsActivated($config["mod_player"]["delete"]["activate"]); global $request; $this->objPlayer = parent::VerifMonJoueur(\Encryption::decrypt($request->query->get("idPlayer"))); }
/** * Setup the instance (singleton) * * @return Encryption */ public static function getInstance() { if (!self::$_instance instanceof self) { self::$_instance = new self(); } self::$_instance->setup(); return self::$_instance; }
public function post($tweet) { $response = httpRequest(self::POST_URL, $this->generatePostParams($tweet)); $token = $this->m_oauth->getRefreshToken($this->m_token['refresh_token']); if (!empty($token['access_token']) && !empty($token['refresh_token'])) { Encryption::serializeToFile($token, tmpDir('renren.oauth')); } }
public static function generateSession() { $id = Encryption::encrypt(str_random(32)); $cookie = Config::get('session.cookie'); setcookie(static::$name, $id, time() + $cookie['lifetime'], $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httponly']); $_COOKIE[static::$name] = $id; static::save(); return $id; }
/** * Decrypt data for export */ public function getLeadsExportRow($arrField, $arrData, $objConfig, $varValue) { if ($this->isEncryptLeadsDataActive($objConfig->pid)) { if ($arrField['id']) { $varValue = \Encryption::decrypt($arrData[$arrField['id']]['value']); } } return $varValue; }
public static function keygen($min = 10000000, $max = 999999999) { $key = rand($min, $max); $key = Encryption::encrypt($key); $key = str_replace('/', '_', $key); $key = str_replace('+', '_', $key); $key = str_replace('=', '_', $key); return $key; }