public function process($slug = NULL)
 {
     if (!$slug) {
         show_404();
     }
     $form = $this->fuel->forms->get($slug);
     $return_url = $this->input->get_post('return_url') ? $this->input->get_post('return_url') : $form->get_return_url();
     $form_url = $this->input->get_post('form_url');
     if ($form and $form->process()) {
         if (is_ajax()) {
             // Set a 200 (okay) response code.
             set_status_header('200');
             echo $form->after_submit_text;
             exit;
         } else {
             $this->session->set_flashdata('success', TRUE);
             redirect($return_url);
         }
     } else {
         $this->session->set_flashdata('posted', $this->input->post());
         if (is_ajax()) {
             // Set a 500 (bad) response code.
             set_status_header('500');
             echo display_errors(NULL, '');
             exit;
         } else {
             if (!empty($form_url) && $form_url != $return_url) {
                 $return_url = $form_url;
                 // update to post back to the correct page when there's an error
             }
             $this->session->set_flashdata('error', $form->errors());
             redirect($return_url);
         }
     }
 }
예제 #2
0
파일: Admin.php 프로젝트: phellmes/hubzilla
 /**
  * @return string
  */
 function get()
 {
     logger('admin_content', LOGGER_DEBUG);
     if (!is_site_admin()) {
         return login(false);
     }
     /*
      * Page content
      */
     $o = '';
     if (argc() > 1) {
         $o = $this->sm->call('get');
         if ($o === false) {
             notice(t('Item not found.'));
         }
     } else {
         $o = $this->admin_page_summary();
     }
     if (is_ajax()) {
         echo $o;
         killme();
         return '';
     } else {
         return $o;
     }
 }
function eventon_prevent_admin_access()
{
    if (get_option('eventon_lock_down_admin') == 'yes' && !is_ajax() && !(current_user_can('edit_posts') || current_user_can('manage_eventon'))) {
        //wp_safe_redirect(get_permalink(woocommerce_get_page_id('myaccount')));
        exit;
    }
}
예제 #4
0
파일: View.php 프로젝트: yang7hua/mall
 public function display($view = null, $vars = null, $return = false)
 {
     $_INS =& get_instance();
     foreach (get_object_vars($_INS) as $_key => $_var) {
         if (!isset($this->{$_key})) {
             $this->{$_key} =& $_INS->{$_key};
         }
     }
     if (is_null($view)) {
         $view = $_INS->get_controller() . '/' . $_INS->get_action();
     }
     $file_exists = false;
     foreach ($this->_view_paths as $path) {
         $view_file = $path . $view . $this->_ext;
         if (file_exists($view_file)) {
             $file_exists = true;
             break;
         }
     }
     $buffer = $this->pick($view_file, $vars);
     if ($return) {
         return $buffer;
     } else {
         $_INS->output->append_output($buffer);
         if (is_ajax()) {
             exit(json_encode($this->_cached_vars));
         }
     }
     return $this;
 }
예제 #5
0
 function vendor_product_restriction()
 {
     global $WCMp;
     if (is_ajax()) {
         return;
     }
     $current_user_id = get_current_user_id();
     if (is_user_wcmp_vendor($current_user_id)) {
         if (isset($_GET['post'])) {
             $current_post_id = $_GET['post'];
             if (get_post_type($current_post_id) == 'product') {
                 if (in_array(get_post_status($current_post_id), array('draft', 'publish', 'pending'))) {
                     $product_vendor_obj = get_wcmp_product_vendors($current_post_id);
                     if ($product_vendor_obj->id != $current_user_id) {
                         wp_redirect(admin_url() . 'edit.php?post_type=product');
                         exit;
                     }
                 }
             } else {
                 if (get_post_type($current_post_id) == 'shop_coupon') {
                     $coupon_obj = get_post($current_post_id);
                     if ($coupon_obj->post_author != $current_user_id) {
                         wp_redirect(admin_url() . 'edit.php?post_type=shop_coupon');
                         exit;
                     }
                 }
             }
         }
     }
 }
예제 #6
0
 public function run()
 {
     if (is_ajax()) {
         $this->add_action('init', array($this, 'runAjax'));
     }
     $this->actionHandler->run();
 }
예제 #7
0
파일: viewsrc.php 프로젝트: Mauru/red
function viewsrc_content(&$a)
{
    $o = '';
    $item_id = argc() > 1 ? intval(argv(1)) : 0;
    $json = argc() > 2 && argv(2) === 'json' ? true : false;
    if (!local_user()) {
        notice(t('Permission denied.') . EOL);
    }
    if (!$item_id) {
        $a->error = 404;
        notice(t('Item not found.') . EOL);
    }
    if (local_user() && $item_id) {
        $r = q("select item_flags, body from item where item_restrict = 0 and uid = %d and id = %d limit 1", intval(local_user()), intval($item_id));
        if ($r) {
            if ($r[0]['item_flags'] & ITEM_OBSCURED) {
                $r[0]['body'] = crypto_unencapsulate(json_decode($r[0]['body'], true), get_config('system', 'prvkey'));
            }
            $o = $json ? json_encode($r[0]['body']) : str_replace("\n", '<br />', $r[0]['body']);
        }
    }
    if (is_ajax()) {
        echo $o;
        killme();
    }
    return $o;
}
 /**
  * form
  */
 function viewAction()
 {
     if ($this->disable === true) {
         return;
     }
     if ($_GET['id']) {
         $data['data'] = $this->obj->view();
     }
     $data['view'] = true;
     if ($_POST && is_ajax()) {
         $setData = $_POST;
         if ($_GET['id']) {
             $condition = ['_id' => new \MongoId($_GET['id'])];
             $rt = $this->obj->updateValidate($condition, $setData);
         } else {
             $rt = $this->obj->insertValidate($setData);
         }
         $data['status'] = 0;
         $data['label'] = '系统未知错误';
         $data['msg'] = '保存数据失败!!!';
         if (is_array($rt) && $rt['errors']) {
             $data['msg'] = $rt['errors'];
         } elseif (is_object($rt)) {
             $data = ['status' => 1, 'msg' => '添加成功', 'label' => '提示信息'];
         } elseif ($rt) {
             $data = ['status' => 1, 'msg' => '更新成功', 'label' => '提示信息'];
         }
         exit(json_encode($data));
     }
     if ($this->data) {
         $data = $data + $this->data;
     }
     $this->data = $data;
     return $this->view($this->view, $data);
 }
 /**
  * Test is_ajax()
  *
  * @since 1.0.0
  */
 public function test_is_ajax()
 {
     if (!defined('DOING_AJAX')) {
         define('DOING_AJAX', true);
     }
     $this->assertEquals(true, is_ajax());
 }
 public function set_status_page()
 {
     if (!is_ajax()) {
         include_once 'class-wc-gzd-admin-status.php';
         add_action('admin_menu', array($this, 'status_menu'), 60);
     }
 }
예제 #11
0
 private function default_vars()
 {
     $curPageFull = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     $curPage = explode("?", $curPageFull);
     $cfg = $this->f3->get('cfg');
     unset($cfg['DB']);
     $this->vars['_isLocal'] = isLocal();
     $this->vars['_version'] = $this->f3->get('_version');
     $this->vars['_v'] = $this->f3->get('_v');
     $this->vars['_cfg'] = $cfg;
     $this->vars['_folder'] = $this->vars['folder'];
     $this->vars['_domain'] = $this->f3->get('domain');
     $this->vars['_api_hits'] = $this->f3->get('_api_hits');
     $this->vars['_user'] = $this->f3->get('user');
     $this->vars['_isAjax'] = is_ajax();
     if ($this->vars['_page']) {
         $page = $this->vars['_page'];
     } else {
         $page = $_SERVER['uri'];
         if ($page == null) {
             $page = "/";
         }
     }
     $this->vars['_page'] = $page;
 }
예제 #12
0
 /**
  * Include any classes we need within admin.
  */
 public function includes()
 {
     // Functions
     include_once 'scf-admin-functions.php';
     //include_once( 'wc-meta-box-functions.php' );
     // Classes
     //include_once( 'class-wc-admin-post-types.php' );
     //include_once( 'class-wc-admin-taxonomies.php' );
     // Classes we only need during non-ajax requests
     if (!is_ajax()) {
         include_once 'class-scf-admin-menus.php';
         //include_once( 'class-wc-admin-welcome.php' );
         //include_once( 'class-wc-admin-notices.php' );
         //include_once( 'class-wc-admin-assets.php' );
         //include_once( 'class-wc-admin-webhooks.php' );
         // Help
         //if ( apply_filters( 'woocommerce_enable_admin_help_tab', true ) ) {
         //	include_once( 'class-wc-admin-help.php' );
         //}
     }
     // Importers
     //if ( defined( 'WP_LOAD_IMPORTERS' ) ) {
     //	include_once( 'class-wc-admin-importers.php' );
     //}
 }
예제 #13
0
function viewsrc_content(&$a)
{
    $o = '';
    $sys = get_sys_channel();
    $item_id = argc() > 1 ? intval(argv(1)) : 0;
    $json = argc() > 2 && argv(2) === 'json' ? true : false;
    if (!local_channel()) {
        notice(t('Permission denied.') . EOL);
    }
    if (!$item_id) {
        App::$error = 404;
        notice(t('Item not found.') . EOL);
    }
    $item_normal = item_normal();
    if (local_channel() && $item_id) {
        $r = q("select id, item_flags, item_obscured, body from item where uid in (%d , %d) and id = %d {$item_normal} limit 1", intval(local_channel()), intval($sys['channel_id']), intval($item_id));
        if ($r) {
            if (intval($r[0]['item_obscured'])) {
                $r[0]['body'] = crypto_unencapsulate(json_decode($r[0]['body'], true), get_config('system', 'prvkey'));
            }
            $o = $json ? json_encode($r[0]['body']) : str_replace("\n", '<br />', $r[0]['body']);
        }
    }
    if (is_ajax()) {
        print '<div><i class="icon-pencil"> ' . t('Source of Item') . ' ' . $r[0]['id'] . '</i></div>';
        echo $o;
        killme();
    }
    return $o;
}
예제 #14
0
 /**
  * @return void
  */
 public function active_free_order()
 {
     try {
         $response = array();
         $fb_id = isset($_POST['post_id']) ? $_POST['post_id'] : 0;
         $redirect_url = isset($_POST['redirect_url']) ? $_POST['redirect_url'] : '';
         if (!$fb_id || !$redirect_url || !is_user_logged_in()) {
             throw new Exception(__('Không thể kích hoạt', NDV_WOO));
             return false;
         }
         $user = wp_get_current_user();
         update_user_meta($user->ID, 'ndv_share', $fb_id);
         $response['status'] = 'success';
         $response['redirect'] = $redirect_url;
         if (is_ajax()) {
             echo '<!--WC_START-->' . json_encode($response) . '<!--WC_END-->';
             exit;
         } else {
             wp_redirect($response['redirect']);
             exit;
         }
     } catch (Exception $e) {
         if (!empty($e)) {
             wc_add_notice($e->getMessage(), 'error');
         }
     }
     if (is_ajax()) {
         ob_start();
         wc_print_notices();
         $messages = ob_get_clean();
         echo '<!--WC_START-->' . json_encode(array('result' => 'failure', 'messages' => isset($messages) ? $messages : '')) . '<!--WC_END-->';
         exit;
     }
 }
 public function controller_init()
 {
     if (!class_exists('WC_Coupon')) {
         return;
     }
     //Admin hooks
     add_action('admin_init', array(&$this, 'admin_init'));
     //Frontend hooks
     //add_action( 'woocommerce_cart_updated',  array( &$this, 'update_matched_autocoupons' ) ); //experiment 2.1.0-b1
     add_action('woocommerce_check_cart_items', array(&$this, 'update_matched_autocoupons'), 0);
     //Remove coupon before WC does it and shows a message
     add_action('woocommerce_before_cart_totals', array(&$this, 'update_matched_autocoupons'));
     //When cart is updated after changing shipping method
     add_action('woocommerce_review_order_before_cart_contents', array(&$this, 'update_matched_autocoupons'));
     //When cart is updated after changing shipping or payment method
     //Last check for coupons with restricted_emails
     add_action('woocommerce_checkout_update_order_review', array($this, 'fetch_billing_email'), 10);
     // AJAX One page checkout
     add_filter('woocommerce_cart_totals_coupon_label', array(&$this, 'coupon_label'), 10, 2);
     add_filter('woocommerce_cart_totals_coupon_html', array(&$this, 'coupon_html'), 10, 2);
     //Inhibit redirect to cart when apply_coupon supplied
     add_filter('option_woocommerce_cart_redirect_after_add', array(&$this, 'option_woocommerce_cart_redirect_after_add'));
     if (!is_ajax()) {
         add_action('wp_loaded', array(&$this, 'coupon_by_url'), 23);
         //Coupon through url
     }
 }
예제 #16
0
function init_module($module)
{
    $modpath = BASEPATH . 'modules/' . $module . '/';
    if (is_dir($modpath)) {
        $modcfg = array('name' => $module, 'path' => $modpath, 'validate' => 'user', 'redirect' => 'login', 'layout' => 'main');
        if (file_exists($modpath . 'config.php')) {
            $config = (include $modpath . 'config.php');
            foreach ($config as $key => $val) {
                $modcfg[$key] = $val;
            }
        }
        $modcfg = json_decode(json_encode($modcfg));
        add_module($module, $modcfg);
        if ($modcfg->validate) {
            if (!has_session($modcfg->validate)) {
                if (is_ajax()) {
                    echo json_encode(array('success' => false, 'message' => __('Your session has been expired !'), 'redirect' => site_url($modcfg->redirect)));
                    exit;
                } else {
                    redirect($modcfg->redirect);
                }
            }
        }
    } else {
        show_404(sprintf(__('Page %s does not found!'), $module));
    }
    return get_module($module);
}
예제 #17
0
 function save_tree()
 {
     // Allow only ajax calls
     if (!is_ajax()) {
         return show_404();
     }
     $this->load->model('categories_model');
     $list = $this->input->post('list');
     // Update db with order posted
     $i = 0;
     foreach ($list as $id => $parent_id) {
         $Category = new Categories_model();
         $node_info_array = array();
         $node_info_array['id'] = $id;
         $node_info_array['parent_id'] = $parent_id == 'root' ? 0 : $parent_id;
         $node_info_array['sort'] = $i;
         // Save Node
         $Category->from_array($node_info_array);
         $Category->save();
         $i++;
     }
     // Clear categories cache so updates will show on next page load
     $this->load->library('categories_library');
     $this->categories_library->clear_cache();
 }
/**
 * Prevent non-admin access to backend
 */
function woocommerce_prevent_admin_access()
{
    if (get_option('woocommerce_lock_down_admin') == 'yes' && !is_ajax() && !current_user_can('edit_posts')) {
        wp_safe_redirect(get_permalink(get_option('woocommerce_myaccount_page_id')));
        exit;
    }
}
예제 #19
0
 function index()
 {
     $this->_validate_user('tools/seo/google_keywords');
     $this->js_controller_params['method'] = 'google_keywords';
     $seo_config = $this->config->item('seo');
     $vars = array();
     $vars['domain'] = $this->input->post('domain') ? $this->input->post('domain') : !empty($seo_config['keyword_search_default_domain']) ? $seo_config['keyword_search_default_domain'] : $_SERVER['SERVER_NAME'];
     $vars['keywords'] = !empty($_POST['keywords']) ? $this->input->post('keywords') : $seo_config['keyword_google_default_keywords'];
     if (is_array($vars['keywords'])) {
         $options = array();
         foreach ($vars['keywords'] as $val) {
             $options[$val] = $val;
         }
         $vars['keywords'] = $options;
     }
     $vars['num_results'] = $seo_config['keyword_google_num_results'];
     if (!empty($_POST['keywords'])) {
         $keywords = explode(',', $this->input->post('keywords'));
         $domain = str_replace(array('http://', 'www'), '', $this->input->post('domain'));
         $ch = curl_init();
         $found = array();
         foreach ($keywords as $keyword) {
             $keyword = trim($keyword);
             $uri = 'http://www.google.com/search?q=' . rawurlencode($keyword) . '&num=' . $seo_config['keyword_google_num_results'] . '&' . http_build_query($seo_config['keyword_google_additional_params']);
             // scrape html from page running on localhost
             $ch = curl_init();
             curl_setopt($ch, CURLOPT_URL, $uri);
             curl_setopt($ch, CURLOPT_HEADER, 0);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
             $google_page = curl_exec($ch);
             preg_match_all('|<h3 class=(["\'])?r\\1?><a.+href="(.+)".+</h3>|Umis', $google_page, $matches);
             // echo "<pre style=\"text-align: left;\">";
             // print_r($matches);
             // echo "</pre>";
             // exit();
             $results = array();
             if (!empty($matches[2])) {
                 $results = $matches[2];
             }
             $num = 1;
             foreach ($results as $uri) {
                 if (strpos($uri, $domain) !== FALSE) {
                     if (!isset($found[$keyword])) {
                         $found[$keyword] = array();
                     }
                     $found[$keyword][] = $num;
                 }
                 $num++;
             }
         }
         curl_close($ch);
         $vars['results'] = $found;
         if (is_ajax()) {
             $this->load->view('google_keywords_result', $vars);
             return false;
         }
     }
     $this->_render('google_keywords', $vars);
 }
/**
 * Wrapper for deprecated arguments so we can apply some extra logic.
 *
 * @since  2.7.0
 * @param  string $argument
 * @param  string $version
 * @param  string $replacement
 */
function wc_deprecated_argument($argument, $version, $message = null)
{
    if (is_ajax()) {
        error_log("The {$argument} argument is deprecated since version {$version}. {$message}");
    } else {
        _deprecated_argument($argument, $version, $message);
    }
}
 public function is_applied_to_product($_product)
 {
     if (is_admin() && !is_ajax()) {
         return false;
     }
     return true;
     //all products are eligibile for the discount.  Only eligibile rulesets for this user have been loaded.
 }
예제 #22
0
 function get_ga_data()
 {
     if (!is_ajax()) {
         return show_404();
     }
     $this->load->model('google_analytics_model');
     $this->google_analytics_model->set_month($this->input->post('month_year'));
     echo $this->google_analytics_model->get_by_type($this->input->post('ga_data_type'));
 }
 public function is_applied_to($_product)
 {
     if (is_admin() && !is_ajax()) {
         return false;
     }
     $process = true;
     //all products are eligibile for the discount.  The role is checked later.
     return apply_filters('woocommerce_dynamic_pricing_process_product_discounts', $process, $_product, $this->discounter, $this);
 }
예제 #24
0
파일: main.php 프로젝트: phith0n/b374k
 function get_post()
 {
     $post = fix_magic_quote($_POST);
     if (empty($_FILES) && is_ajax()) {
         $post_str = rc4($GLOBALS['cipher_key'], hex2bin($post['target']));
         parse_str($post_str, $post);
         $post = fix_magic_quote($post);
     }
     return $post;
 }
예제 #25
0
파일: functions.php 프로젝트: cruide/wasp
function is_wasp_ajax()
{
    global $_SERVER;
    if (is_ajax()) {
        if (isset($_SERVER['HTTP_X_REQUEST_TYPE']) && $_SERVER['HTTP_X_REQUEST_TYPE'] == 'Expedited') {
            return true;
        }
    }
    return false;
}
function woocommerce_afs_filter_free_shipping($rates)
{
    if ((is_checkout() || is_cart() || is_ajax() && isset($_POST['action']) && 'woocommerce_update_order_review' === $_POST['action']) && isset($rates['free_shipping'])) {
        foreach ($rates as $key => $value) {
            if ('free_shipping' !== $key) {
                unset($rates[$key]);
            }
        }
    }
    return $rates;
}
예제 #27
0
파일: Node.php 프로젝트: Crocodile26/php-1
 function _list()
 {
     if (is_ajax()) {
         list($offset, $size, $p) = $this->limit();
         $total = $this->node->total();
         $this->load->library('page', [$total, $size, $p], 'page');
         $nodes = $this->node->select($offset, $size);
         $this->success(['list' => $nodes, 'page' => $this->page->getPage()]);
     }
     return $this->load->view('node/list');
 }
 /**
  * includes function
  */
 function includes()
 {
     if (!is_ajax()) {
         include_once WC()->plugin_path() . '/includes/admin/class-wc-admin-assets.php';
     } elseif (is_ajax() && is_admin()) {
         // Add files required for AJAX calls by this plugin
         include_once WC()->plugin_path() . '/includes/admin/settings/class-wc-settings-page.php';
         require_once 'inc/class-settings-categories.php';
         require_once 'inc/class-settings-products.php';
     }
 }
 function index()
 {
     if (!is_ajax()) {
         $vars['summaries'] = $this->fuel->campaign_monitor->render(TRUE);
         $crumbs = array('tools' => lang('section_tools'), lang('campaign_monitor_titlebar'));
         $this->fuel->admin->set_titlebar($crumbs, 'ico_tools_campaign_monitor');
         $this->fuel->admin->render('_admin/campaign_monitor', $vars, '', CAMPAIGN_MONITOR_FOLDER);
     } else {
         $this->fuel->campaign_monitor->render();
     }
 }
예제 #30
0
 function _list()
 {
     if (is_ajax()) {
         list($offset, $size, $p) = $this->limit();
         $total = $this->product_attr->total();
         $this->load->library('page', [$total, $size, $p], 'page');
         $list = $this->product_attr->ok_select($size, $offset);
         $this->success(['list' => $list, 'page' => $this->page->getPage()]);
     }
     $attrs = $this->product_attr->attrs();
     return $this->load->view('product/attr_list', ['attrs' => $attrs]);
 }