コード例 #1
0
 public static function setConfig()
 {
     $module = new PayqrModule();
     PayqrConfig::$merchantID = $module->getOption("merchantID");
     PayqrConfig::$secretKeyIn = $module->getOption("secretKeyIn");
     PayqrConfig::$secretKeyOut = $module->getOption("secretKeyOut");
 }
コード例 #2
0
ファイル: PayqrReceiver.php プロジェクト: rakot9/diafanpayqr
 /**
  * Задаём настройки
  */
 private function setModuleConfig()
 {
     $user_id = isset($_GET["user_id"]) ? $_GET["user_id"] : 1;
     $auth = new PayqrModuleAuth($user_id);
     $module = new PayqrModule();
     PayqrConfig::$merchantID = $module->getOption("merchantID");
     PayqrConfig::$secretKeyIn = $module->getOption("secretKeyIn");
     PayqrConfig::$secretKeyOut = $module->getOption("secretKeyOut");
 }
コード例 #3
0
 public function getLogUrl()
 {
     $url = "";
     $auth = new PayqrModuleAuth();
     if ($user = $auth->getUser()) {
         $url = PayqrModule::getBaseUrl() . "/log.php?user_id={$user->user_id}&key={$this->log_key}";
     }
     return $url;
 }
コード例 #4
0
 public function register($post)
 {
     if ($post["password"] != $post["password_repeat"]) {
         return "Пароли не совпадают";
     }
     $db = PayqrModuleDb::getInstance();
     $user = $db->select("select * from " . PayqrModuleDb::getUserTable() . " where username = ?", array($post["username"]), array("s"));
     if ($user) {
         return "Пользователь с таким именем уже существует";
     }
     $auth = new PayqrModuleAuth();
     $password = $auth->encodePassword($post["password"]);
     $id = $db->insert(PayqrModuleDb::getUserTable(), array("username" => $post["username"], "password" => $password), array("%s", "%s"));
     $auth = new PayqrModuleAuth($id);
     PayqrModule::redirect("auth");
 }
コード例 #5
0
 public function getHtml()
 {
     $step = isset($_GET["step"]) ? $_GET["step"] : 1;
     $install = new PayqrModuleInstall();
     $html = "";
     switch ($step) {
         case 1:
             if (isset($_POST["username"]) && !empty($_POST["username"])) {
                 if ($install->saveDbConfig($_POST)) {
                     PayqrModule::redirect("install", array("step" => "2"));
                 } else {
                     $html .= "<div class='error'>Неверные доступы в бд</div>";
                 }
             }
             $html .= "<form id='auth_form' method='post'>";
             $html .= "<div>Введите данные для доступа к бд</div>";
             $html .= "<input type='hidden' name='step1'/>";
             $html .= "<div><label>Имя пользователя: <input type='text' name='username'/></label></div>";
             $html .= "<div><label>Пароль: <input type='password' name='password'/></label></div>";
             $html .= "<div><label>Имя базы данных: <input type='text' name='database'/></label></div>";
             $html .= "<div><label>Префикс таблиц: <input type='text' name='prefix'/></label></div>";
             $html .= "<div><label>Хост: <input type='text' value='localhost' name='host'/></label></div>";
             $html .= "<div><input type='submit' value='Отправить'/></div>";
             $html .= "</form>";
             break;
         case 2:
             $install->createTables();
             if (isset($_POST["step2"])) {
                 $msg = $install->register($_POST);
                 $html .= "<div class='error'>{$msg}</div>";
             }
             $html .= "<form id='auth_form' method='post'>";
             $html .= "<input type='hidden' name='step2'/>";
             $html .= "<div>Введите данные для входа в кабинет</div>";
             $html .= "<div><label>Имя пользователя: <input type='text' name='username'/></label></div>";
             $html .= "<div><label>Пароль: <input type='password' name='password'/></label></div>";
             $html .= "<div><label>Повторите пароль: <input type='password' name='password_repeat'/></label></div>";
             $html .= "<div><input type='submit' value='Отправить'/></div>";
             $html .= "</form>";
             break;
         default:
             $html = "<h1>Установка завершена</h1>";
             break;
     }
     return $html;
 }
コード例 #6
0
 private function recoverUser()
 {
     if (isset($_COOKIE[$this->key])) {
         $db = PayqrModuleDb::getInstance();
         $user = $db->select("select user_id, username, merch_id from " . PayqrModuleDb::getUserTable() . " where md5(concat(user_id, username, '" . $this->salt . "')) = ?", array($_COOKIE[$this->key]), array("s"));
         if ($user) {
             $_SESSION[$this->key] = $user;
         }
     } else {
         $location = PayqrModule::getBaseUrl() . "/module/auth/";
         $auth_location = "http://{$_SERVER['SERVER_NAME']}{$_SERVER['REQUEST_URI']}";
         if ($location != $auth_location) {
             header("Location: {$location}");
         }
         $_SESSION[$this->key] = false;
     }
 }
コード例 #7
0
 /**
  * Получить значение для настроек кнопки
  * 
  * @param string $key
  * @return string
  */
 private function getOption($key)
 {
     $module = new PayqrModule();
     $value = $module->getOption($key);
     return $value;
 }
コード例 #8
0
ファイル: index.php プロジェクト: rakot9/diafanpayqr
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
$step = isset($_GET["step"]) ? $_GET["step"] : 1;
require_once __DIR__ . '/../../PayqrConfig.php';
$install = new PayqrModuleInstall();
$html = "";
switch ($step) {
    case 1:
        if ($install->checkDbConfigConn()) {
            PayqrModule::redirect("/module/install/index.php?step=2");
        } else {
            if (isset($_POST["username"]) && !empty($_POST["username"])) {
                if ($install->saveDbConfig($_POST)) {
                    PayqrModule::redirect("/module/install/index.php?step=2");
                } else {
                    $html .= "<div class='error'>Неверные доступы в бд</div>";
                }
            }
            $html .= "<form method='post'>";
            $html .= "<div>Введите данные для доступа к бд</div>";
            $html .= "<input type='hidden' name='step1'/>";
            $html .= "<div><label>Имя пользователя: <input type='text' name='username'/></label></div>";
            $html .= "<div><label>Пароль: <input type='password' name='password'/></label></div>";
            $html .= "<div><label>Имя базы данных: <input type='text' name='database'/></label></div>";
            $html .= "<div><label>Префикс таблиц: <input type='text' name='prefix'/></label></div>";
            $html .= "<div><label>Хост: <input type='text' value='localhost' name='host'/></label></div>";
            $html .= "<div><input type='submit' value='Отправить'/></div>";
            $html .= "</form>";
        }
コード例 #9
0
 public function revertOrder()
 {
     //отправка сообщений
     $module = new PayqrModule();
     if ($module->getOption("message-invoice-reverted")) {
         $message = $this->invoice->getMessage();
         if ($message) {
             $message->article = $module->getOption("message-invoice-reverted-article");
             $message->text = $module->getOption("message-invoice-reverted-text");
             $message->imageUrl = $module->getOption("message-invoice-reverted-imageUrl");
             $message->url = $module->getOption("message-invoice-reverted-url");
             $this->invoice->setMessage($message);
         }
     }
 }
コード例 #10
0
ファイル: InvoiceHandler.php プロジェクト: rakot9/diafanpayqr
 public function revertOrder()
 {
     PayqrLog::log("revertOrder");
     $order_id = $this->invoice->getOrderId();
     PayqrLog::log("revertOrder получили номер заказа: " . $order_id);
     if (!empty($order_id)) {
         //получаем статус заказа "в обработке"
         $status_id = DB::query_result("SELECT id FROM {shop_order_status} WHERE status='2' LIMIT 1");
         PayqrLog::log("cancelOrder получили статус заказа 'Отменен': " . $status_id);
         //меняем статус заказа
         DB::query("UPDATE {shop_order} set status_id=%d WHERE id=%d", $status_id, $order_id);
         PayqrLog::log("cancelOrder произвели обновление статуса заказа: ");
     }
     //отправка сообщений
     $module = new PayqrModule();
     if ($module->getOption("message-invoice-reverted")) {
         $message = $this->invoice->getMessage();
         if ($message) {
             $message->article = $module->getOption("message-invoice-reverted-article");
             $message->text = $module->getOption("message-invoice-reverted-text");
             $message->imageUrl = $module->getOption("message-invoice-reverted-imageUrl");
             $message->url = $module->getOption("message-invoice-reverted-url");
             $this->invoice->setMessage($message);
         }
     }
 }
コード例 #11
0
ファイル: PayqrModule.php プロジェクト: rakot9/diafanpayqr
 public static function redirect($url)
 {
     $location = PayqrModule::getBaseUrl() . $url;
     header("Location: {$location}");
 }
コード例 #12
0
ファイル: log.php プロジェクト: payqrphpdev/php-module
<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
require_once __DIR__ . "/PayqrConfig.php";
$key = PayqrConfig::$logKey;
if (empty($key)) {
    $module = new PayqrModule();
    $key = $module->getOption("logKey");
}
if (isset($_GET["key"]) && $_GET["key"] == $key) {
    $text = PayqrLog::showLog();
} else {
    $text = "Введён неверный ключ доступа к логам";
}
echo $text;