Esempio n. 1
0
function password_form($output = '')
{
    if (empty($id = get_the_ID())) {
        return $output;
    }
    return sprintf('%1$s<form action="%2$s" class="%3$s" method="post"><label for="%4$s" class="screen-reader-text">%5$s</label><input name="post_password" id="%4$s" type="password" size="20" required=""%6$s/><button id="submit" type="submit" name="submit"%7$s>%8$s</button></form>', sprintf('<p>%s</p>', esc_html(option('prompt'))), esc_url(site_url('wp-login.php?action=postpass', 'login_post')), option('class'), esc_attr('password-input-' . intval($id)), esc_html__('Password', 'ubik'), option('input_style') ? ' style="' . esc_attr(option('input_style')) . '"' : '', option('button_style') ? ' style="' . esc_attr(option('button_style')) . '"' : '', option('button'));
}
Esempio n. 2
0
 public static function delete($file)
 {
     if (empty($file)) {
         return false;
     }
     if (function_exists('option')) {
         $bucket = option('config.attachment_up_bucket');
         $user = option('config.attachment_up_username');
         $pwd = option('config.attachment_up_password');
         $unlink = option('config.attachment_upload_unlink');
     } else {
         $bucket = C('config.attachment_up_bucket');
         $user = C('config.attachment_up_username');
         $pwd = C('config.attachment_up_password');
         $unlink = C('config.attachment_upload_unlink');
     }
     if (empty($bucket) || empty($user) || empty($pwd)) {
         return false;
     }
     if (empty($unlink)) {
         return false;
     }
     $upyun = new UpYun($bucket, $user, $pwd);
     try {
         error_log('upyunUser::delete:' . $file);
         $upyun->delete($file);
     } catch (Exception $e) {
         print_r($e);
     }
 }
Esempio n. 3
0
 /**
  * 根据产品ID获得优惠活动
  * $product_id_arr 产品ID数组
  * $store_id 店铺ID
  * $uid 店铺UID
  */
 public function getListByProductId($product_id_arr, $store_id, $uid)
 {
     $tmp_product_id_arr = array();
     foreach ($product_id_arr as $tmp) {
         $tmp_product_id_arr[] = $tmp['product_id'];
     }
     $time = time();
     $db_prefix = option('system.DB_PREFIX');
     $sql = "SELECT distinct u.* FROM `" . $db_prefix . "user_coupon` AS u LEFT JOIN `" . $db_prefix . "coupon_to_product` AS cp ON `u`.`coupon_id` = `cp`.`coupon_id` WHERE `u`.`store_id` = '" . $store_id . "' AND (`u`.`is_all_product` = 0 or `cp`.`product_id` in (" . join(',', $tmp_product_id_arr) . ")) AND `u`.`uid` = '" . $uid . "' AND `u`.`start_time` <= '" . $time . "' AND `u`.`end_time` >= '" . $time . "' AND `u`.`is_use` = '0' AND `u`.is_valid = '1' AND `u`.`delete_flg` = '0'";
     $user_coupon_list = $this->db->query($sql);
     foreach ($user_coupon_list as &$user_coupon) {
         $where = array();
         $where['coupon_id'] = $user_coupon['coupon_id'];
         // 优惠参加产品
         if ($user_coupon['is_all_product'] == 1) {
             $product_list = M('Coupon_to_product')->getList($where);
             $product_id_arr = array();
             foreach ($product_list as $tmp) {
                 $product_id_arr[$tmp['product_id']] = $tmp['product_id'];
             }
             $user_coupon['product_list'] = $product_id_arr;
         } else {
             $user_coupon['product_list'] = array();
         }
     }
     return $user_coupon_list;
 }
Esempio n. 4
0
 /**
  * 根据产品ID获得优惠活动
  * $product_id_arr 产品ID数组
  * $store_id 店铺ID
  * $uid 店铺UID
  */
 public function getListByProductId($product_id_arr, $store_id, $uid)
 {
     $time = time();
     $db_prefix = option('system.DB_PREFIX');
     $sql = "SELECT distinct r.* FROM `" . $db_prefix . "reward` AS r LEFT JOIN `" . $db_prefix . "reward_product` AS rp ON `r`.`id` = `rp`.`rid` WHERE `r`.`store_id` = '" . $store_id . "' AND (`r`.`is_all` = 1 or `rp`.`product_id` in (" . join(',', $product_id_arr) . ")) AND `r`.`uid` = '" . $uid . "' AND `r`.`status` = '1' AND `r`.`start_time` <= '" . $time . "' AND `r`.`end_time` >= '" . $time . "'";
     $reward_list = $this->db->query($sql);
     foreach ($reward_list as &$reward) {
         $where = array();
         $where['rid'] = $reward['id'];
         // 优惠条件
         $reward_condition_list = M('Reward_condition')->getList($where, 0, 0, 'id desc');
         $reward['condition_list'] = $reward_condition_list;
         // 优惠参加产品
         if ($reward['is_all'] == 2) {
             $reward_product_list = M('Reward_product')->getList($where);
             $product_id_arr = array();
             foreach ($reward_product_list as $tmp) {
                 $product_id_arr[$tmp['product_id']] = $tmp['product_id'];
             }
             $reward['product_list'] = $product_id_arr;
         } else {
             $reward['product_list'] = array();
         }
     }
     return $reward_list;
 }
function configure()
{
    option('views_dir', APP_ROOT . '/views');
    option('lib_dir', APP_ROOT . '/lib');
    option('base_uri', '/');
    option('debug', false);
}
Esempio n. 6
0
function get_posts($query)
{
    if (is_tax('series') && $query->is_main_query()) {
        $query->set('order', option('order'));
    }
    return $query;
}
Esempio n. 7
0
 /**
  * setUp.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $view = new View();
     $view->theme(option('front_theme'));
     $this->helper = new MenuHelper($view);
 }
Esempio n. 8
0
function configure()
{
    $cfg = ActiveRecord\Config::instance();
    $cfg->set_model_directory("models");
    $cfg->set_connections(array("development" => "mysql://*****:*****@localhost/hello_world?charset=utf8"));
    option("bas_url", "/");
}
Esempio n. 9
0
 function filteredgrid()
 {
     $this->datasis->modulo_id(106, 1);
     $this->rapyd->load("datafilter", "datagrid");
     //
     $filter = new DataFilter("Filtro por Partidas", "partida");
     $filter->id_part = new inputField("Identificador", "id_part");
     $filter->id_part->size = 5;
     $filter->part_pres = new inputField("C&oacute;digo", "part_pres");
     $filter->part_pres->size = 5;
     $filter->nomb_part = new inputField("Nombre", "nomb_part");
     $filter->nomb_part->size = 40;
     $filter->conf_part = new dropdawnField("Condici&oacute;n", "conf_part");
     $filter->conf_part = option('S', 'Si');
     $filter->conf_part = option('N', 'Ni');
     $filter->nro_cta->style = 'width:300px;';
     $filter->buttons("reset", "search");
     $filter->build();
     $uri = anchor('presupuesto/partida/dataedit/show/<#id_unid#>', '<#id_unid#>');
     $grid = new DataGrid("Lista de Unidades Ejecutoras");
     $grid->order_by("cod_unid", "asc");
     $grid->column("Identificador", $uri, "align='left'");
     $grid->column("Unidades Ejecutoras", "cod_unid", "align='left'");
     $grid->column("Nombre", "nomb_unid", "align='left'");
     $grid->add("presupuesto/partida/dataedit/create");
     $grid->build();
     $data['content'] = $filter->output . $grid->output;
     $data['title'] = " Partidas ";
     $data["head"] = $this->rapyd->get_head();
     $this->load->view('view_ventanas', $data);
 }
Esempio n. 10
0
function configure()
{
    option('views_dir', '../app/views');
    option('controllers_dir', '../app/controllers');
    option('encoding', 'utf-8');
    layout('layouts/default.html.php');
}
Esempio n. 11
0
function redirect()
{
    global $wp_rewrite;
    if (!is_search() || is_admin() || !isset($wp_rewrite) || !is_object($wp_rewrite) || !$wp_rewrite->get_search_permastruct()) {
        return;
    }
    // Set the search base and query
    $search_base = $wp_rewrite->search_base;
    $search_query = get_query_var('s');
    // Skip the search results if there is exactly one result: http://wpglee.com/2011/04/redirect-when-search-query-only-returns-one-match/
    if (option('redirect_single') && $search_query) {
        global $wp_query;
        if ($wp_query->post_count == 1) {
            wp_redirect(esc_url(trailingslashit(get_permalink($wp_query->posts['0']->ID))));
            exit;
        }
    }
    // Return a random post when an empty search query is entered
    // Allows the random results to be filtered (e.g. to limit to a particular category, post types, or anything else accepted by `get_posts`)
    if (option('redirect_random') && $search_query === '') {
        $random = get_posts(apply_filters('ubik_search_redirect_random_args', ['numberposts' => 1, 'orderby' => 'rand']));
        wp_redirect(esc_url(trailingslashit(get_permalink($random[0]->ID))));
        exit;
    }
    // "Nice search" rewrite; full credit to Mark Jaquith for this functionality: https://wordpress.org/plugins/nice-search/
    if (strpos($_SERVER['REQUEST_URI'], "/{$search_base}/") === false && strpos($_SERVER['REQUEST_URI'], '&') === false) {
        //wp_redirect( esc_url( trailingslashit( home_url( "/{$search_base}/" . urlencode($search_query) ) ) ) );
        wp_redirect(get_search_link());
        exit;
    }
}
Esempio n. 12
0
function hydrate_model($file)
{
    if (is_file($file) && strpos($file, '.php')) {
        preg_match_all('/class\\s(\\S+)\\s/', read($file), $match);
        require $file;
        foreach ($match[1] as $klass) {
            $re = new \ReflectionClass($klass);
            switch ($re->getParentClass()->getName()) {
                case 'Servant\\Mapper\\Database':
                    status('hydrate', $file);
                    $dsn = option('database.' . $klass::CONNECTION);
                    $db = \Grocery\Base::connect($dsn);
                    $columns = $klass::columns();
                    $indexes = $klass::indexes();
                    if (!isset($db[$klass::table()])) {
                        $db[$klass::table()] = $columns;
                    }
                    \Grocery\Helpers::hydrate($db[$klass::table()], $columns, $indexes);
                    break;
                case 'Servant\\Mapper\\MongoDB':
                    status('hydrate', $file);
                    $dsn_string = \Servant\Config::get($klass::CONNECTION);
                    $database = substr($dsn_string, strrpos($dsn_string, '/') + 1);
                    $mongo = $dsn_string ? new \Mongo($dsn_string) : new \Mongo();
                    $db = $mongo->{$database ?: 'default'};
                    \Servant\Helpers::reindex($db->{$klass::table()}, $klass::indexes());
                    break;
                default:
                    break;
            }
        }
    }
}
Esempio n. 13
0
 public function pay()
 {
     if (empty($this->pay_config['pay_weixin_appid']) || empty($this->pay_config['pay_weixin_mchid']) || empty($this->pay_config['pay_weixin_key'])) {
         return array('err_code' => 1, 'err_msg' => '微信支付缺少配置信息!请联系管理员处理或选择其他支付方式。');
     }
     if (empty($this->openid)) {
         return array('err_code' => 1, 'err_msg' => '没有获取到用户的微信资料,无法使用微信支付');
     }
     import('source.class.pay.Weixinnewpay.WxPayPubHelper');
     $jsApi = new JsApi_pub($this->pay_config['pay_weixin_appid'], $this->pay_config['pay_weixin_mchid'], $this->pay_config['pay_weixin_key']);
     $unifiedOrder = new UnifiedOrder_pub($this->pay_config['pay_weixin_appid'], $this->pay_config['pay_weixin_mchid'], $this->pay_config['pay_weixin_key']);
     $unifiedOrder->setParameter('openid', $this->openid);
     $unifiedOrder->setParameter('body', $this->order_info['order_no_txt']);
     $unifiedOrder->setParameter('out_trade_no', $this->order_info['trade_no']);
     $unifiedOrder->setParameter('total_fee', floatval($this->order_info['total'] * 100));
     $unifiedOrder->setParameter('notify_url', option('config.wap_site_url') . '/paynotice.php');
     $unifiedOrder->setParameter('trade_type', 'JSAPI');
     $unifiedOrder->setParameter('attach', 'weixin');
     $prepay_result = $unifiedOrder->getPrepayId();
     if ($prepay_result['return_code'] == 'FAIL') {
         return array('err_code' => 1, 'err_msg' => '没有获取微信支付的预支付ID,请重新发起支付!<br/><br/>微信支付错误返回:' . $prepay_result['return_msg']);
     }
     if ($prepay_result['err_code']) {
         return array('err_code' => 1, 'err_msg' => '没有获取微信支付的预支付ID,请重新发起支付!<br/><br/>微信支付错误返回:' . $prepay_result['err_code_des']);
     }
     $jsApi->setPrepayId($prepay_result['prepay_id']);
     return array('err_code' => 0, 'pay_data' => $jsApi->getParameters());
 }
Esempio n. 14
0
 public function add()
 {
     if (isPost()) {
         return $this->_add();
     }
     $row = array('card' => m('Member')->getNewCard(option('member_unit')), 'shop_id' => session('shop_id'), 'level_discount' => '1', 'money' => '0.00', 'consume' => '0.00', 'point' => '0.00');
     $this->view()->assign('title', '新增会员')->assign('action', url('Member', 'add'))->assign('row', $row)->assign('my_shop', getMyShop())->assign('member_level', getMemberLevel())->display('member_form');
 }
Esempio n. 15
0
 public function add()
 {
     if (isPost()) {
         return $this->_add();
     }
     $row = array('sn' => m('Customer')->getNewSn(option('customer_unit')), 'shop_id' => session('shop_id'), 'discount' => '1', 'money' => '0.00', 'consume' => '0.00', 'point' => '0.00', 'offer' => '0.00', 'overdraft' => '0.00', 'status' => '1');
     $this->view()->assign('title', '新增客户')->assign('action', url('Customer', 'add'))->assign('row', $row)->assign('my_shop', getMyShop())->display('customer_form');
 }
function public_url_for($path)
{
    $args = func_get_args();
    $paths = array(option('base_path'));
    $paths[] = 'public';
    $paths = array_merge($paths, $args);
    return call_user_func_array('file_path', $paths);
}
Esempio n. 17
0
 public function getFxProducts($order_id)
 {
     $products = $this->db->query("SELECT p.product_id,p.name,fop.cost_price,p.image,fop.quantity,fop.price,fop.sku_id,fop.sku_data,fop.comment FROM " . option('system.DB_PREFIX') . "fx_order_product fop, " . option('system.DB_PREFIX') . "product p WHERE fop.product_id = p.product_id AND fop.fx_order_id = '" . $order_id . "'");
     foreach ($products as &$tmp) {
         $tmp['image'] = getAttachmentUrl($tmp['image']);
     }
     return $products;
 }
Esempio n. 18
0
function configure()
{
    option('root_dir', dirname(__DIR__));
    option('views_dir', dirname(__DIR__) . DIRECTORY_SEPARATOR . 'views');
    option('controllers_dir', dirname(__DIR__) . DIRECTORY_SEPARATOR . 'controllers');
    option('lib_dir', dirname(__DIR__) . DIRECTORY_SEPARATOR . 'lib');
    option('public_dir', __DIR__);
}
Esempio n. 19
0
 function getPersUserData()
 {
     $ci =& get_instance();
     if (!$ci->session->userdata("user_id")) {
         redirect(option("site_url") . "/security/login", "refresh");
         exit;
     }
 }
Esempio n. 20
0
function configure()
{
    option('env', ENV_PRODUCTION);
    option('debug', false);
    option('base_uri', '<TPL:NGINX_LOCATION>/');
    layout('layout.html.php');
    define('PUBLIC_DIR', '<TPL:NGINX_LOCATION>/public');
}
Esempio n. 21
0
function block_elements($content)
{
    $elements = option('block_elements');
    if (!empty($elements)) {
        $content = preg_replace('/<(' . implode('|', $elements) . ')>/', '<$1 markdown="1">', $content);
    }
    return $content;
}
Esempio n. 22
0
 /**
  * Gets content's details page URL.
  *
  * Content's details URL's follows the syntax below:
  *
  *     http://example.com/{content-type-slug}/{content-slug}{CONTENT_EXTENSION}
  *
  * Example:
  *
  *     http://example.com/blog-article/my-first-article.html
  *
  * @return string
  */
 protected function _getUrl()
 {
     $url = Router::getRequest()->base;
     if (option('url_locale_prefix')) {
         $url .= '/' . I18n::locale();
     }
     $url .= "/{$this->content_type_slug}/{$this->slug}";
     return Router::normalize($url) . CONTENT_EXTENSION;
 }
Esempio n. 23
0
function quick_edit_init()
{
    foreach (apply_filters('ubik_admin_terms_quick_edit_taxonomies', option('quick_edit')) as $tax) {
        add_action("edited_{$tax}", __NAMESPACE__ . '\\quick_edit_save');
        add_filter("manage_edit-{$tax}_columns", __NAMESPACE__ . '\\quick_edit_column');
        add_filter("manage_{$tax}_custom_column", __NAMESPACE__ . '\\quick_edit_column_contents', 10, 3);
        add_filter("get_user_option_manageedit-{$tax}columnshidden", __NAMESPACE__ . '\\quick_edit_column_visibility');
    }
}
Esempio n. 24
0
 protected function checkFx($return = false)
 {
     $open_platform_drp = option('config.open_platform_drp');
     if ($return) {
         return $this->open_platform_drp = $open_platform_drp;
     } else {
         $this->assign('allow_platform_drp', $open_platform_drp);
     }
 }
Esempio n. 25
0
function configure()
{
    option('app_dir', file_path(dirname(option('root_dir')), 'app'));
    option('lib_dir', file_path(option('app_dir'), 'lib'));
    option('views_dir', file_path(option('app_dir'), 'views'));
    option('session', "app_session");
    option('debug', false);
    setlocale(LC_TIME, "ro_RO");
}
Esempio n. 26
0
function test_output_render_file()
{
    $response = test_request(TESTS_DOC_ROOT . '02-outputs.php/text', 'GET', true);
    assert_header($response, 'Content-type', 'text/plain; charset=' . option('encoding'));
    $response = test_request(TESTS_DOC_ROOT . '02-outputs.php/jpeg', 'GET', true);
    assert_header($response, 'Content-type', 'image/jpeg');
    $response = test_request(TESTS_DOC_ROOT . '02-outputs.php/unknown_page', 'GET', true);
    assert_header($response, 'Content-type', 'text/html; charset=' . option('encoding'));
}
Esempio n. 27
0
function debug_msg($message)
{
    $messages = option('debug_msg');
    if (!is_array($messages)) {
        $messages = array();
    }
    $messages[] = $message;
    option('debug_msg', $messages);
}
Esempio n. 28
0
 public function getList($where)
 {
     $sql = 'SELECT *,COUNT(\'pigcms_id\') AS pv, COUNT(DISTINCT(\'module\')) AS uv FROM ' . option('system.DB_PREFIX') . 'store_analytics WHERE store_id = \'' . $where['store_id'] . '\'';
     if (!empty($where['_string'])) {
         $sql .= ' AND ' . $where['_string'];
     }
     $sql .= ' GROUP BY module ORDER BY pv DESC, uv DESC';
     return $this->db->query($sql);
 }
Esempio n. 29
0
function example()
{
    // The $options array is not available inside namespaced functions; use the option() function instead
    if (option('feature')) {
        $example = "Feature is on";
    } else {
        $example = "Feature is off";
    }
    echo apply_filters('ubik_example_filter', $example);
}
Esempio n. 30
-1
function authorize()
{
    global $api;
    $story_app = NULL;
    // Successful authorization. Store the access token in the session
    if (!isset($_GET['error'])) {
        try {
            $api->authenticate('authorization_code', array('code' => $_GET['code'], 'redirect_uri' => option('OAUTH_REDIRECT_URI')));
            $_SESSION['access_token'] = $api->oauth->access_token;
            $_SESSION['refresh_token'] = $api->oauth->refresh_token;
            $story_app = $api->app->get(STORY_APP_ID);
        } catch (PodioError $e) {
            die("There was an error. The API responded with the error type <b>{$e->body['error']}</b> and the message <b>{$e->body['error_description']}</b><br><a href='" . url_for('/') . "'>Go back</a>");
        }
    }
    if ($story_app) {
        $_SESSION['story_app'] = $story_app;
        $_SESSION['space'] = $api->space->get($_SESSION['story_app']['space_id']);
        redirect_to('');
    } else {
        // Something went wrong. Display appropriate error message.
        unset($_SESSION['access_token']);
        unset($_SESSION['refresh_token']);
        $error_description = !empty($_GET['error_description']) ? htmlentities($_GET['error_description']) : 'You do not have access to the ScrumIO apps. Try logging in as a different user.';
        return html('login.html.php', NULL, array('oauth_url' => option('OAUTH_URL'), 'error_description' => $error_description));
    }
}