예제 #1
0
 public function test_rewrite_func_url_user()
 {
     $this->assertEquals('http://' . self::$host . '/', url_user('/'));
     $this->assertEquals('http://' . self::$host . '/profile/1', url_user('/profile/1'));
     $this->assertEquals('http://' . self::$host . '/profile/1', url_user('/profile/show/1'));
     $this->assertEquals('http://' . self::$host . '/profile/view/1', url_user('/profile/view/1'));
 }
 public function _init()
 {
     if (!$this->ENABLE) {
         return null;
     }
     // default
     $purse = $this->_purse_by_currency(['is_key' => false]);
     if ($purse['status'] === false) {
         throw new InvalidArgumentException($purse['status_message']);
     }
     // load api
     $provider_path = __DIR__ . '/payment_provider/webmoney';
     // CA: https://wiki.wmtransfer.com/projects/webmoney/wiki/WebMoney_root_certificate
     $this->CA = $provider_path . '/WebMoneyCA.pem';
     require_once $provider_path . '/WebMoney.php';
     $this->api = new WebMoney($purse['id'], $purse['key'], $purse['hash_method']);
     $this->url_result = url_user('/api/payment/provider?name=webmoney&operation=response');
     $this->url_server = url_user('/api/payment/provider?name=webmoney&operation=response&server=true');
     // DEBUG
     $is_test = $this->is_test();
     if ($is_test) {
         $this->SHOP_ID = 21;
     }
     if ($is_test && @$_GET['result_test']) {
         $result_test = $_GET['result_test'] == '1' || $_GET['result_test'] == 'true' ? 1 : 0;
         // test: 0 - success; 1 - fail.
         // $_[ 'LMI_SIM_MODE' ] = 0;
         // $_[ 'LMI_SIM_MODE' ] = 1;
         $_SESSION['payin']['result_test'] = $result_test;
     }
     // parent
     parent::_init();
 }
 public function _init()
 {
     if (!$this->ENABLE) {
         return null;
     }
     // load api
     require_once __DIR__ . '/payment_provider/ecommpay/EcommPay.php';
     $this->api = new EcommPay($this->KEY_PUBLIC, $this->KEY_PRIVATE);
     $this->url_result = url_user('/api/payment/provider?name=ecommpay&operation=response');
     $this->url_server = url_user('/api/payment/provider?name=ecommpay&operation=response&server=true');
     // translation
     $strs =& $this->method_allow['payout']['pay_card']['option'];
     foreach ($strs as $key => &$str) {
         $str = t($str);
     }
     // payout default option
     $user_id = main()->USER_ID;
     if ($user_id) {
         $user = user($user_id);
         $option_default =& $this->method_allow['payout']['pay_card']['option_default'];
         $option_default = ['card' => $user['card'], 'sender_first_name' => $user['first_name'], 'sender_last_name' => $user['last_name'], 'sender_middle_name' => $user['middle_name'] ?: $user['patronymic'], 'sender_passport_number' => $user['passport_num'], 'sender_passport_issue_date' => $user['passport_issue_date'], 'sender_passport_issued_by' => $user['passport_issued_by'] ?: $user['passport_released'], 'sender_phone' => @str_replace([' ', '-', '+'], '', $user['phone']), 'sender_birthdate' => $user['birthdate'] ?: $user['birth_date'], 'sender_address' => $user['address'] ?: $user['address2'], 'sender_city' => $user['city'] ?: $user['city2'], 'sender_postindex' => $user['zip_code'] ?: $user['zip_code2']];
         $option_default =& $this->method_allow['payout']['qiwi']['option_default'];
         $option_default = ['account_number' => @str_replace([' ', '-', '+'], '', $user['phone'])];
     }
     // parent
     parent::_init();
 }
예제 #4
0
 protected function _operation_form()
 {
     // import options
     is_array($_GET) && extract($_GET, EXTR_PREFIX_ALL | EXTR_REFS, '');
     is_array($_POST) && extract($_POST, EXTR_PREFIX_ALL | EXTR_REFS, '_');
     // var
     $api = _class('api');
     $payment_api = _class('payment_api');
     $result = [];
     // check input data
     list($account_id, $account) = $payment_api->get_account();
     if (empty($account_id)) {
         js_redirect('/login_form', false, 'User id empty');
     }
     // operation
     $operation = $payment_api->operation(['operation_id' => $_operation_id]);
     if (!$operation) {
         $result = ['status' => false, 'status_message' => t('Операция отсутствует (id: %operation_id)', ['%operation_id' => $_operation_id])];
         return $this->_operation_tpl($result);
     }
     // user
     $user_id = main()->USER_ID;
     if ($user_id != $account['user_id']) {
         return $api->_reject();
     }
     // import operation
     is_array($operation) && extract($operation, EXTR_PREFIX_ALL | EXTR_REFS, 'o');
     // prepare data
     $data = ['title' => $o_title, 'amount' => $payment_api->money_html($o_amount)];
     $form = ['code' => @$__code ?: @$_code, 'action' => url_user($_SERVER['REQUEST_URI'])];
     $result = ['data' => $data, 'form' => $form];
     return $result;
 }
예제 #5
0
    /**
     */
    function edit()
    {
        $a = $this->_get_info();
        if (!$a) {
            return _404();
        }
        $a['back_link'] = url('/@object');
        $form_id = 'content_form';
        jquery('
			var form_id = "' . $form_id . '";
			var bak_action = $("form#" + form_id).attr("action");
			var preview_url = "' . url_user('/dynamic/preview/static_pages/' . $a['id']) . '";
			$("[type=submit].preview", "form#" + form_id).on("click", function() {
				$(this).closest("form").attr("target", "_blank").attr("action", preview_url)
			})
			$("[type=submit]:not(.preview)", "form#" + form_id).on("click", function() {
				$(this).closest("form").attr("target", "").attr("action", bak_action)
			})
		');
        // Prevent execution of template tags when editing page content
        $exec_fix = ['{' => '{', '}' => '}'];
        $keys_to_fix = ['text'];
        foreach ((array) $keys_to_fix as $k) {
            if (false !== strpos($a[$k], '{') && false !== strpos($a[$k], '}')) {
                $a[$k] = str_replace(array_keys($exec_fix), array_values($exec_fix), $a[$k]);
            }
        }
        $a = (array) $_POST + (array) $a;
        if (is_post()) {
            foreach ((array) $keys_to_fix as $k) {
                if (false !== strpos($_POST[$k], '{') && false !== strpos($_POST[$k], '}')) {
                    $_POST[$k] = str_replace(array_values($exec_fix), array_keys($exec_fix), $_POST[$k]);
                }
            }
        }
        $_this = $this;
        return form($a, ['hide_empty' => true, 'id' => $form_id])->validate(['__before__' => 'trim', 'name' => ['required', function (&$in) use($_this) {
            $in = $_this->_fix_page_name($in);
            return (bool) strlen($in);
        }, function ($name, $tmp, $d, &$error) use($_this, $a) {
            $id = db()->from($_this::table)->where('locale', $a['locale'])->where('name', $name)->get_one('id');
            if ($id && $id != $a['id']) {
                $error = t('Page with this name and locale already exists');
            }
            return $error ? false : true;
        }], 'text' => 'required'])->update_if_ok(self::table, ['name', 'text', 'page_title', 'page_heading', 'meta_keywords', 'meta_desc', 'active'], 'id=' . $a['id'])->on_before_update(function () use($a, $_this) {
            module_safe('manage_revisions')->add(['object_name' => $_this::table, 'object_id' => $a['id'], 'old' => $a, 'new' => $_POST, 'action' => 'update']);
        })->on_after_update(function () {
            common()->admin_wall_add(['static page updated: ' . $a['name'], $a['id']]);
            cache_del('static_pages_names');
        })->container($this->_get_lang_links($a['locale'], $a['name'], 'edit'))->text('name')->textarea('text', ['id' => 'text', 'cols' => 200, 'rows' => 10, 'ckeditor' => ['config' => _class('admin_methods')->_get_cke_config()]])->text('page_title')->text('page_heading')->text('meta_keywords')->text('meta_desc')->active_box()->save_and_back()->preview();
    }
 public function _init()
 {
     if (!$this->ENABLE) {
         return null;
     }
     $this->payment_api = _class('payment_api');
     // load api
     require_once __DIR__ . '/payment_provider/interkassa/Interkassa.php';
     $this->api = new Interkassa($this->KEY_PUBLIC, $this->KEY_PRIVATE, $this->KEY_PRIVATE_TEST, $this->HASH_METHOD, $this->TEST_MODE);
     $this->url_result = url_user('/api/payment/provider?name=interkassa&operation=response');
     $this->url_server = url_user('/api/payment/provider?name=interkassa&operation=response&server=true');
     // parent
     parent::_init();
 }
 public function _init()
 {
     if (!$this->ENABLE) {
         return null;
     }
     if (empty($this->url_server)) {
         $this->url_server = url_user('/api/payment/provider?name=bitcoin&operation=response&server=true');
     }
     $allow = $this->allow();
     if (!$allow) {
         return false;
     }
     parent::_init();
 }
 public function _init()
 {
     if (!$this->ENABLE) {
         return null;
     }
     $this->payment_api = _class('payment_api');
     // load api
     require_once __DIR__ . '/payment_provider/privat24/Privat24.php';
     $this->api = new Privat24($this->KEY_PUBLIC, $this->KEY_PRIVATE);
     $this->url_result = url_user('/api/payment/provider?name=privat24&operation=response');
     $this->url_server = url_user('/api/payment/provider?name=privat24&operation=response&server=true');
     // parent
     parent::_init();
 }
 public function _init()
 {
     if (!$this->ENABLE) {
         return null;
     }
     if (empty($this->url_server)) {
         $this->url_server = url_user('/api/payment/provider?name=payeer&operation=response&server=true');
     }
     $allow = $this->allow();
     if (!$allow) {
         return false;
     }
     if (!empty($this->PARTNER_ID)) {
         $this->URL_MERCHANT_API .= '?partner=' . $this->PARTNER_ID;
         //$this->URL_API .= '?partner='.$this->PARTNER_ID;
     }
     parent::_init();
 }
 public function _init()
 {
     if (!$this->ENABLE) {
         return null;
     }
     // parent
     parent::_init();
     // class
     $payment_api =& $this->payment_api;
     $provider_name =& $this->provider_name;
     $provider_id =& $this->provider_id;
     $provider =& $this->provider;
     $access_token =& $this->access_token;
     // load api
     require_once __DIR__ . '/payment_provider/yandexmoney/YandexMoney.php';
     $this->api = new YandexMoney($this->KEY_PUBLIC, $this->KEY_PRIVATE);
     $this->url_result = url_user('/api/payment/provider?name=yandexmoney&operation=response');
     $this->url_server = url_user('/api/payment/provider?name=yandexmoney&operation=response&server=true');
     $this->url_authorize = url_user('/api/payment/provider?name=yandexmoney&operation=authorize&server=true');
     // provider options
     list($provider_id, $provider) = $payment_api->get_provider(['name' => $provider_name]);
     $access_token = @$provider['options']['authorize']['access_token'];
     !is_string($access_token) && ($access_token = null);
 }
예제 #11
0
 public function mail($options = null)
 {
     // DEBUG
     // ini_set( 'html_errors', 0 );
     // var_dump( $options );
     $result = true;
     // import options
     is_array($options) && extract($options, EXTR_PREFIX_ALL | EXTR_REFS, '');
     // tpl by type, status
     if (empty($_tpl) && !(empty($_type) && empty($_status))) {
         $_tpl = $_type . '_' . $_status;
     }
     if (empty($_tpl)) {
         return null;
     }
     if (empty($_type) || empty($_status)) {
         list($type, $status) = @explode('_', $_tpl);
         if (!@$_type && @$type) {
             $_type = $type;
             $options['type'] = $_type;
         }
         if (!@$_status && @$status) {
             $_status = $status;
             $options['status'] = $_status;
         }
     }
     // DEBUG
     // ini_set( 'html_errors', 0 );
     // var_dump( $options );
     // var
     $payment_api = $this;
     $mail_class = _class('email');
     // error off
     /*
     		$mail_debug = $mail_class->MAIL_DEBUG;
     		$mail_class->MAIL_DEBUG = false;
     		$send_mail_class = _class( 'send_mail' );
     		$send_mail_debug = $send_mail_class->MAIL_DEBUG;
     		$send_mail_class->MAIL_DEBUG = false;
     */
     // check user
     if (@$_user_id > 0) {
         $user_mail = $this->is_user_mail($options);
         // check email, validate email
         if (!@$_force && !@$user_mail['status']) {
             return $user_mail;
         }
         $user = $user_mail['user'];
         $mail_to = $user['email'];
         $mail_name = $user['name'];
     }
     // DEBUG
     // ini_set( 'html_errors', 0 );
     // var_dump( $mail_to, $mail_name );
     // check data
     $data = [];
     if (!empty($_data)) {
         // import data
         is_array($_data) && extract($_data, EXTR_PREFIX_ALL | EXTR_REFS, '_');
         // amount
         if (!empty($__amount)) {
             $__amount = $payment_api->money_text($__amount);
         }
         $data = $_data;
     }
     // url
     $url = ['user_payments' => url_user('/payments')];
     switch ($status) {
         case 'confirmation':
             $url['user_confirmation'] = url_user(['object' => 'payment', 'operation_id' => @$__operation_id, 'code' => @$__code, 'is_confirmation' => 1]);
             $url['user_confirmation_cancel'] = url_user(['object' => 'payment', 'operation_id' => @$__operation_id, 'is_cancel' => 1]);
             break;
     }
     // mail
     $mail_admin_to = $mail_class->ADMIN_EMAIL;
     $mail_admin_name = $mail_class->ADMIN_NAME;
     $mail = ['support_mail' => $mail_admin_to, 'support_name' => $mail_admin_name];
     // compile
     $data = array_replace_recursive($data, ['url' => $url, 'mail' => $mail]);
     $is_admin = !empty($_is_admin);
     $admin = !empty($_admin);
     // user
     if (!$is_admin) {
         $r = @$mail_class->_send_email_safe($mail_to, $mail_name, $_tpl, $data);
         // mail fail
         !$r && $this->mail_log(['name' => 'mail_user', 'data' => ['status' => 'fail', 'operation_id' => $__operation_id, 'user_id' => $_user_id, 'mail' => $mail_to, 'name' => $mail_name, 'tpl' => $_tpl]]);
         $result &= $r;
         // mail copy
         !$admin && $this->mail_copy(['tpl' => $_tpl, 'type' => $_type, 'status' => $_status, 'subject' => @$_subject, 'data' => $data]);
     }
     // admin
     if ($admin || $is_admin) {
         $url = ['user_manage' => $this->url_admin(['object' => 'members', 'action' => 'edit', 'id' => $_user_id]), 'user_balance' => $this->url_admin(['object' => 'manage_payment', 'action' => 'balance', 'user_id' => $_user_id]), 'manage_payin' => $this->url_admin(['object' => 'manage_deposit', 'action' => 'view', 'operation_id' => $__operation_id]), 'manage_payout' => $this->url_admin(['object' => 'manage_payout', 'action' => 'view', 'operation_id' => $__operation_id])];
         // compile
         $data = array_replace_recursive($data, ['url' => $url, 'user_title' => $user['name'] . ' (id: ' . $_user_id . ')']);
         $tpl = $_tpl . '_admin';
         $r = @$mail_class->_send_email_safe($mail_admin_to, $mail_admin_name, $tpl, $data);
         // mail fail
         !$r && $this->mail_log(['name' => 'mail_admin', 'data' => ['status' => 'fail', 'operation_id' => $__operation_id, 'user_id' => $_user_id, 'mail' => $mail_admin_to, 'name' => $mail_admin_name, 'tpl' => $tpl]]);
         // mail copy
         $result_copy = $this->mail_copy(['tpl' => $tpl, 'type' => $_type, 'status' => $_status, 'subject' => @$_subject, 'data' => $data]);
         !$result_copy && $this->mail_copy(['tpl' => $_tpl, 'type' => $_type, 'status' => $_status, 'subject' => @$_subject, 'data' => $data]);
     }
     /*
     		$mail_class->MAIL_DEBUG      = $mail_debug;
     		$send_mail_class->MAIL_DEBUG = $send_mail_debug;
     */
     return $result;
 }
 function _data_ng($json = false)
 {
     $cache =& $this->cache;
     $_url = ['product_view' => url_user(['object' => 'shop', 'action' => 'product', 'id' => 0]), 'product_edit' => url_admin(['object' => 'manage_shop', 'action' => 'product_edit', 'id' => 0])];
     $_upload_list = $this->upload_list;
     $_upload_status = $this->upload_status;
     $_import_field = $this->import_field;
     $_import_field_autodetect = $this->import_field_autodetect;
     $_import_action = $this->import_action;
     $_import_action_array = [];
     foreach ($_import_action as $key => $value) {
         $_import_action_array[] = ['key' => $key, 'value' => $value];
     }
     // supplier
     $_supplier = $cache['supplier']['id'];
     $_supplier_array = [];
     $_supplier_array[] = ['id' => null, 'title' => 'поставщик'];
     foreach ($_supplier as $id => $item) {
         $title = $item['name'];
         $_supplier_array[] = ['id' => $id, 'title' => $title . ' (' . $id . ')'];
     }
     // category
     $_category = $cache['category']['id'];
     $_category_array = [];
     $_category_array[] = ['id' => null, 'title' => 'категория'];
     foreach ($_category as $id => $item) {
         $title = $item['name'];
         $_category_array[] = ['id' => $id, 'title' => $title . ' (' . $id . ')'];
     }
     $result = ['_url' => $_url, '_upload_status' => $_upload_status, '_upload_list' => $_upload_list, '_import_field' => $_import_field, '_import_field_autodetect' => $_import_field_autodetect, '_import_action' => $_import_action, '_import_action_array' => $_import_action_array, '_supplier' => $_supplier, '_supplier_array' => $_supplier_array, '_category' => $_category, '_category_array' => $_category_array];
     if ($json) {
         $result = json_encode($result, JSON_NUMERIC_CHECK);
     }
     return $result;
 }
예제 #13
0
 /**
  * Endpoint for oauth logins
  */
 function oauth($params = [])
 {
     if (!isset($params['only_icons'])) {
         $params['only_icons'] = 1;
     }
     if (!$_GET['id'] && !$this->OAUTH_LIST_PROVIDERS && empty($params)) {
         if (main()->USER_ID) {
             return js_redirect('./');
         } else {
             return js_redirect('./?object=login_form');
         }
     }
     #		$allowed_objects = array('login','login_form','register','user_profile','profile')
     $allowed_objects = ['login_form', 'user_profile', 'profile'];
     $def_object = 'login_form';
     $url_object = in_array($_GET['object'], $allowed_objects) ? $_GET['object'] : 'login_form';
     $url_action = __FUNCTION__;
     if (in_array($_GET['object'], $allowed_objects) && $_GET['id'] && preg_match('/^[a-z0-9_-]+$/ims', $_GET['id'])) {
         return _class('oauth')->login($_GET['id']);
     }
     $body = [];
     foreach ((array) $providers as $name => $settings) {
         if ($name[0] == '_') {
             continue;
         }
         $href = url_user('/' . $url_object . '/' . $url_action . '/' . $name);
         $img_web_path = 'https://s3-eu-west-1.amazonaws.com/yfix/oauth/providers/' . $name . '.png';
         $body[] = '<a href="' . $href . '">' . '<img src="' . $img_web_path . '" style="height:32px;padding-right:2px;">' . (!$params['only_icons'] ? ' ' . $name : '') . '</a>';
     }
     return implode(PHP_EOL, $body);
 }
예제 #14
0
파일: yf_table2.class.php 프로젝트: yfix/yf
 /**
  */
 function footer_link($name, $link, $extra = [])
 {
     $item = ['type' => __FUNCTION__, 'name' => $name, 'extra' => $extra, 'link' => $link, 'func' => function ($params, $instance_params, $table) {
         $extra = $params['extra'];
         $id = isset($extra['id']) ? $extra['id'] : 'id';
         $link = $params['link'] . $instance_params['links_add'];
         if (strlen($link)) {
             $link = $table->_process_link_params($link, $row, $extra + ['id' => $id]);
             if (!$table->_is_link_allowed($link)) {
                 return '';
             }
         }
         if ($extra['rewrite']) {
             if ($extra['rewrite'] === 'user') {
                 $link = url_user($link);
             } elseif ($extra['rewrite'] === 'admin') {
                 $link = url_admin($link);
             } else {
                 $link = url($link);
             }
         }
         $extra['href'] = $link;
         $icon = $extra['icon'] ? ' ' . $extra['icon'] : $table->CLASS_ICON_BTN;
         $class = $extra['class'] ?: $extra['a_class'] ?: $table->CLASS_BTN_MINI;
         if ($extra['class_add']) {
             $class .= ' ' . $extra['class_add'];
         }
         if ($extra['no_ajax'] || $instance_params['no_ajax']) {
             $class .= ' ' . $table->CLASS_NO_AJAX;
         }
         $extra['class'] = $class;
         return '<a' . _attrs($extra, ['href', 'class', 'title']) . '><i class="' . $icon . '"></i> ' . t($params['name']) . '</a> ';
     }];
     if (!$extra['display_in']) {
         $extra['display_in'] = 'footer';
     }
     if ($extra['display_in'] == 'header' || $extra['copy_to_header']) {
         $this->_header_links[] = $item;
     }
     if ($extra['display_in'] == 'footer' || $extra['copy_to_footer']) {
         $this->_footer_links[] = $item;
     }
     return $this;
 }
예제 #15
0
<?php

return function () {
    return ['versions' => ['master' => ['js' => ['
	var yf_ajax_link_validate = "' . url_user('/dynamic/ajax_validate') . '";
	var yf_ajax_validate_cache = { };
	var yf_css_class_error = "error has-error";
	var yf_css_icon_error = "icon icon-large icon-ban-circle fa fa-2x fa-times-circle text-error text-danger";
	var yf_css_icon_success = "icon icon-large icon-ok-circle fa fa-2x fa-check-circle text-success";
	var yf_css_icon_refresh = "icon icon-large icon-refresh fa fa-2x fa-refresh text-info";
	var yf_html_help_block = "<span class=\\"help-block pull-left\\"></span>";
	var yf_title_error = "' . t('not good') . '";
	var yf_title_success = "OK";
', <<<END
\$(function(){
\t\$("input[data-ajax-validate]", "form")
\t.not("[data-fv-field]")
\t.on("blur", function(i) {
\t\tvar _this = \$(this);
\t\tvar _val = _this.val();
\t\tif (!_val.length) {
\t\t\treturn false;
\t\t}
\t\tif (typeof _this[0].validity == "object") {
\t\t\tyf_ajax_validation_icon_clear(_this)
\t\t\tif (!_this[0].validity.valid) {
\t\t\t\treturn false;
\t\t\t}
\t\t}
\t\tvar validate_rules_str = _this.attr("data-ajax-validate");
\t\tvar result = "";
예제 #16
0
 function product_edit()
 {
     $id = (int) $_GET['id'];
     $_GET['id'] = $id;
     if (empty($id)) {
         return _e('Empty id');
     }
     $product_info = module('manage_shop')->_product_get_info($id);
     if (empty($product_info['id'])) {
         return _e('Product not found');
     }
     // prepare region
     $_region = _class('_shop_region', 'modules/shop/')->_get_list();
     $region = _class('_shop_region', 'modules/shop/')->_get_by_product_ids($id, $force = true);
     $region = $region[$id];
     // -----
     if (main()->is_post()) {
         // TODO: use validation from form2()
         if (!$_POST['name']) {
             _re('Product name must be filled', 'name');
         }
         if (!common()->_error_exists()) {
             module('manage_shop')->_product_check_first_revision('product', $id);
             $sql = ['url' => $_POST['url'] ?: common()->_propose_url_from_name($_POST['name']), 'active' => intval((bool) $_POST['active']), 'update_date' => time()];
             foreach (['name', 'description', 'model', 'articul', 'cat_id', 'meta_keywords', 'meta_desc', 'featured', 'external_url', 'sku', 'stock_status_id', 'manufacturer_id', 'supplier_id', 'quantity'] as $k) {
                 if (isset($_POST[$k])) {
                     $sql[$k] = $_POST[$k];
                 }
             }
             foreach (['price', 'price_promo', 'price_partner', 'price_raw', 'old_price'] as $k) {
                 if (isset($_POST[$k])) {
                     $sql[$k] = number_format($_POST[$k], 2, '.', '');
                 }
             }
             db()->update_safe(db('shop_products'), $sql, 'id=' . $id);
             if (!empty($_FILES)) {
                 module('manage_shop')->_product_image_upload($id);
             }
             $params_to_insert = [];
             foreach ((array) $_POST['productparams'] as $param_id) {
                 db()->query('DELETE FROM ' . db('shop_products_productparams') . ' WHERE product_id=' . $id);
                 $param_id = intval($param_id);
                 if (!$param_id) {
                     continue;
                 }
                 foreach ((array) $_POST['productparams_options_' . $param_id] as $v) {
                     $params_to_insert[] = ['product_id' => $id, 'productparam_id' => $param_id, 'value' => $v];
                 }
             }
             if ($params_to_insert) {
                 db()->insert_safe('shop_products_productparams', $params_to_insert);
             }
             $product_to_category_insert = [];
             foreach ((array) $_POST['category'] as $_cat_id) {
                 $_cat_id = intval($_cat_id);
                 if (!$_cat_id) {
                     continue;
                 }
                 $product_to_category_insert[] = ['product_id' => $id, 'category_id' => $_cat_id];
             }
             if ($product_to_category_insert) {
                 db()->query('DELETE FROM ' . db('shop_product_to_category') . ' WHERE product_id=' . $id);
                 db()->insert_safe(db('shop_product_to_category'), $product_to_category_insert);
             }
             $product_related_insert = [];
             foreach ((array) $_POST['product_related'] as $related_id) {
                 $related_id = intval($related_id);
                 if (!$related_id) {
                     continue;
                 }
                 $product_related_insert[] = ['product_id' => $id, 'related_id' => $related_id];
             }
             if ($product_related_insert) {
                 db()->query('DELETE FROM ' . db('shop_product_related') . ' WHERE product_id=' . $id);
                 db()->insert_safe(db('shop_product_related'), $product_related_insert);
             }
             // update region
             $_table = 'shop_product_to_region';
             $_post = _class('_shop_region', 'modules/shop/')->_check_by_product_id($_POST['region']);
             $_insert = array_diff($_post, $region);
             $_delete = array_diff($region, $_post);
             // insert
             if (!empty($_insert)) {
                 $_data = [];
                 foreach ($_insert as $_id) {
                     $_data[] = ['product_id' => $id, 'region_id' => $_id];
                 }
                 db_query('START TRANSACTION');
                 db()->insert_on_duplicate_key_update($_table, $_data);
                 db_query('COMMIT');
             }
             // delete
             if (!empty($_delete)) {
                 $_data = ['__args__' => [['product_id', 'in', $id], 'and', ['region_id', 'in', $_delete]]];
                 db_query('START TRANSACTION');
                 db()->delete($_table, $_data);
                 db_query('COMMIT');
             }
             $region = _class('_shop_region', 'modules/shop/')->_get_by_product_ids($id, true);
             $region = $region[$id];
             // -----
             $product_to_unit_insert = [];
             foreach ((array) $_POST['units'] as $_unit_id) {
                 $_unit_id = (int) $_unit_id;
                 if (empty($_unit_id)) {
                     continue;
                 }
                 $product_to_unit_insert[] = ['product_id' => $id, 'unit_id' => $_unit_id];
             }
             db()->query('DELETE FROM ' . db('shop_product_to_unit') . ' WHERE product_id=' . $id);
             if ($product_to_unit_insert) {
                 db()->insert_safe(db('shop_product_to_unit'), $product_to_unit_insert);
             }
             module('manage_shop')->_attributes_save($id);
             module('manage_shop')->_product_add_revision('edit', $id);
             module('manage_shop')->_product_cache_purge($id);
             common()->admin_wall_add(['shop product updated: ' . $_POST['name'], $id]);
             // sphinx reindex by flag file
             exec('touch /tmp/sphinx/indexer-kupi');
             exec('touch /tmp/sphinx/indexer-kupi_dev');
         }
         return js_redirect('./?object=' . main()->_get('object') . '&action=product_edit&id=' . $id);
     }
     $media_host = defined('MEDIA_HOST') ? MEDIA_HOST : false;
     $base_url = WEB_PATH;
     if (!empty($media_host)) {
         $base_url = '//' . $media_host . '/';
     }
     $images_items = [];
     foreach ((array) common()->shop_get_images($product_info['id']) as $a) {
         $images_items[] = tpl()->parse('manage_shop/image_items', ['img_path' => $base_url . $a['big'], 'thumb_path' => $base_url . $a['thumb'], 'del_url' => './?object=' . main()->_get('object') . '&action=product_image_delete&id=' . $product_info['id'] . '&key=' . $a['id'], 'image_key' => $a['id'], 'data-test' => 'delete_image_btn']);
     }
     $products_to_category = [];
     foreach ((array) db()->get_all('SELECT category_id FROM ' . db('shop_product_to_category') . ' WHERE product_id=' . $id) as $a) {
         $products_to_category[$a['category_id']] = $a['category_id'];
     }
     $products_to_unit = [];
     foreach ((array) db()->get_all('SELECT unit_id FROM ' . db('shop_product_to_unit') . ' WHERE product_id=' . $id) as $a) {
         $products_to_unit[$a['unit_id']] = $a['unit_id'];
     }
     $replace = $product_info + ['form_action' => './?object=' . main()->_get('object') . '&action=product_edit&id=' . $product_info['id'], 'back_url' => './?object=' . main()->_get('object') . '&action=products', 'units' => $products_to_unit];
     $textarea_id = 'description';
     return form($replace, ['for_upload' => 1, 'currency' => module('manage_shop')->CURRENCY, 'hide_empty' => 1, 'tabs' => ['class' => 'span6 col-md-6', 'show_all' => 1, 'no_headers' => 1]])->tab_start('tab_desc', ['tab_body' => ['class' => 'active span12 col-md-12']])->textarea('description', ['style' => 'min-width:100%', 'cols' => 200, 'rows' => 10, 'ckeditor' => ['config' => _class('admin_methods')->_get_cke_config()]])->tab_end()->tab_start('main')->link('product_url_user', url_user('/shop/product/' . $product_info['id']), ['target' => '_blank'])->info('id')->text('name')->text('articul')->text('url')->chosen_box('cat_id', module('manage_shop')->_cats_for_select, ['desc' => 'Main category', 'edit_link' => './?object=category_editor&action=show_items&id=shop_cats', 'translate' => 0, 'data-test' => 'select_category'])->chosen_box('manufacturer_id', module('manage_shop')->_man_for_select, ['desc' => 'Manufacturer', 'edit_link' => './?object=' . main()->_get('object') . '&action=manufacturers', 'translate' => 0, 'data-test' => 'select_manufacturer'])->chosen_box('supplier_id', module('manage_shop')->_suppliers_for_select, ['desc' => 'Supplier', 'edit_link' => './?object=' . main()->_get('object') . '&action=suppliers', 'data-test' => 'select_supplier'])->select2_box(['desc' => 'Регион', 'name' => 'region', 'multiple' => true, 'values' => $_region, 'selected' => $region, 'edit_link' => url_admin('/manage_shop/region'), 'data-test' => 'select_region'])->number('quantity', ['min' => 0])->active_box('active')->tab_end()->tab_start('params')->link('Search images', './?object=' . main()->_get('object') . '&action=product_image_search&id=' . $product_info['id'], ['class_add' => 'btn-success', 'data-test' => 'search_image_btn'])->container(($images_items ? implode(PHP_EOL, $images_items) : '') . '<a class="btn btn-default btn-mini btn-xs" data-test="add_image" onclick="addImage();"><span>' . t('Add Image') . '</span></a> <div id="images"></div>', ['desc' => 'Images'])->link('Set main image', './?object=' . $_GET['object'] . '&action=set_main_image&id=' . $product_info['id'], ['class_add' => 'ajax_edit', 'data-test' => 'set_main_image_btn', 'display_func' => function () use($images_items) {
         return is_array($images_items) && count($images_items) > 1;
     }])->container(module('manage_shop')->_productparams_container($id), ['desc' => 'Product params'])->select2_box(['desc' => 'Ед. измерения', 'name' => 'units', 'multiple' => true, 'values' => module('manage_shop')->_units_for_select, 'edit_link' => url_admin('/manage_shop/units'), 'data-test' => 'select_units'])->price('old_price')->price('price')->price('price_promo')->price('price_partner')->price('price_raw')->tab_end()->tab_start('tab_save', ['tab_body' => ['class' => 'active span12 col-md-12']])->save_and_back()->tab_end() . tpl()->parse('manage_shop/product_edit_js');
 }
예제 #17
0
파일: yf_email.class.php 프로젝트: yfix/yf
 /**
  */
 function _get_email_text($replace = [], $extra = [])
 {
     if ($extra['tpl_name']) {
         $lang = $extra['locale'] ?: conf('language');
         $a = db()->from(self::table_tpls)->where('name', $extra['tpl_name'])->where('locale', $lang)->get();
         if (!$a) {
             $a = db()->from(self::table_tpls)->where('name', $extra['tpl_name'])->get();
         }
     }
     if ($extra['subject']) {
         $a['subject'] = $extra['subject'];
     }
     $body = $a['text'] ?: $extra['body'];
     if ($a['parent_id']) {
         $parent = db()->from(self::table_tpls)->whereid($a['parent_id'])->where('locale', $a['locale'])->get();
         if (!$parent) {
             $parent = db()->from(self::table_tpls)->whereid($a['parent_id'])->get();
         }
         if ($parent) {
             $body = tpl()->parse_string($parent['text'], ['main_content' => $body]);
         }
     }
     $subject = strip_tags($a['subject']);
     if (empty($subject) && empty($body)) {
         return false;
     }
     $replace = (array) $replace + ['site_name' => $this->SITE_NAME, 'site_url' => $this->SITE_URL, 'unsubscribe_url' => url_user('/unsubscribe/show/' . $extra['tpl_name'] . '-' . time())];
     return [tpl()->parse_string($subject, $replace), tpl()->parse_string($body, $replace)];
 }
예제 #18
0
파일: links.lib.php 프로젝트: laiello/yakbb
function link_user($userid, $username, $display, $groupid = 0)
{
    return '<a href="' . url_user($userid, $username, $display) . '" class="group' . $groupid . '">' . $display . '</a>';
}
예제 #19
0
 /**
  */
 function login_as($id)
 {
     if (!$id) {
         return _e('Wrong id');
     }
     $a = db()->from('user')->whereid($id)->get();
     if (!$a) {
         return _e('Target user not found');
     }
     $t = time();
     $secret_key = db()->get_one('SELECT MD5(CONCAT(`password`, "' . str_replace(['http://', 'https://'], '//', INCLUDE_PATH) . '")) FROM ' . db('admin') . ' WHERE id=1');
     $to_encode = 'userid-' . $a['id'] . '-' . $t . '-' . md5($a['password']);
     $integrity_hash = md5($to_encode);
     $encrypted = _class('encryption')->_safe_encrypt_with_base64($to_encode . '-' . $integrity_hash, $secret_key);
     if (tpl()->REWRITE_MODE) {
         $url = url_user(['task' => 'login', 'id' => $encrypted], parse_url(WEB_PATH, PHP_URL_HOST));
     } else {
         $url = WEB_PATH . '?task=login&id=' . $encrypted;
     }
     return js_redirect($url, $rewrite = false);
 }
예제 #20
0
 protected function _payin_WebMoney($title)
 {
     $url = 'https://merchant.webmoney.ru/lmi/payment.asp';
     $title = 'Пополнение счета';
     $title = base64_encode($title);
     // $title = iconv( 'utf-8', 'windows-1251', $title );
     $url_result = url_user('/payment_test/provider?status=result');
     $url_success = url_user('/payment_test/provider?status=success');
     $url_fail = url_user('/payment_test/provider?status=fail');
     $options = $this->_options($title);
     $api = _class('payment_api__provider_webmoney');
     $form = $api->_form($options);
     $submit = '<img src="http://wiki.webmoney.ru/images/wm/logo-wm.png" />';
     return [$form, $submit];
 }
예제 #21
0
 public function test_https_only()
 {
     $old = main()->USE_ONLY_HTTPS;
     main()->USE_ONLY_HTTPS = true;
     $GLOBALS['PROJECT_CONF']['tpl']['REWRITE_MODE'] = true;
     $this->assertEquals('https://' . self::$host . '/', url_user());
     $this->assertEquals('https://' . self::$host . '/', url_user(''));
     $this->assertEquals('https://' . self::$host . '/', url_user('/'));
     $this->assertEquals('https://' . self::$host . '/', url_user('/////'));
     $this->assertEquals('https://' . self::$host . '/#frag', url_user('/#frag'));
     $_GET['object'] = 'testobj';
     $this->assertEquals('https://' . self::$host . '/' . $_GET['object'] . '/testme/4', url_user('/@object/testme/4'));
     $_GET['object'] = 'testobj2';
     $this->assertEquals('https://' . self::$host . '/' . $_GET['object'] . '/testme/4', url_user('/@object/testme/4'));
     $this->assertEquals('https://' . self::$host . '/' . $_GET['object'] . '/testme/4#frag', url_user('/@object/testme/4#frag'));
     $GLOBALS['PROJECT_CONF']['tpl']['REWRITE_MODE'] = false;
     $this->assertEquals('https://' . self::$host . '/', url_user());
     $this->assertEquals('https://' . self::$host . '/', url_user(''));
     $this->assertEquals('https://' . self::$host . '/', url_user('/'));
     $this->assertEquals('https://' . self::$host . '/', url_user('/////'));
     $this->assertEquals('https://' . self::$host . '/#frag', url_user('/#frag'));
     $_GET['object'] = 'testobj';
     $this->assertEquals('https://' . self::$host . '/?object=' . $_GET['object'] . '&action=testme&id=4', url_user('/@object/testme/4'));
     $_GET['object'] = 'testobj2';
     $this->assertEquals('https://' . self::$host . '/?object=' . $_GET['object'] . '&action=testme&id=4', url_user('/@object/testme/4'));
     $this->assertEquals('https://' . self::$host . '/?object=' . $_GET['object'] . '&action=testme&id=4#frag', url_user('/@object/testme/4#frag'));
     main()->USE_ONLY_HTTPS = $old;
 }