コード例 #1
0
ファイル: fn.admin.php プロジェクト: baden03/access48
/**
 * Check API
 *
 * @return void
 */
function cx_api($c = null, $force = false, $recheck = false)
{
    global $CX;
    $lc = get_option('cx_c9f1a6384b1c466d4612f513bd8e13ea');
    $lce = get_option('cx_error');
    $_lk = !empty($CX->opts['license_key']) ? $CX->opts['license_key'] : '';
    if (defined(cx_('Q1hfQUNUSVZBVEVfSw==')) && !$force) {
        if (empty($lc)) {
            update_option('cx_c9f1a6384b1c466d4612f513bd8e13ea', cx_('QWN0aXZlIGxpY2Vuc2U=') . ': ' . CX_ACTIVATE_T . '<small style="display:block;max-width:500px;color:#999" class="description">' . cx_('QXV0by11cGRhdGVzIG5vdCBzdXBwb3J0ZWQuIFBsZWFzZSBrZWVwIHlvdXIgdGhlbWUgdXAtdG8tZGF0ZS4gSWYgeW91IHdhbnQsIHlvdSBjYW4gcHVyY2hhc2UgYSBDWCBsaWNlbnNlIHRvIGdldCBhdXRvLXVwZGF0ZXMgYW5kIGZyZWUgc3VwcG9ydCBmcm9tIFNjcmVldHMu') . '.</small>');
            return;
        }
    }
    if (!$recheck && $_lk == $c && !empty($lc)) {
        return;
    }
    // don't recheck again
    if (!$force && (!empty($lc) || !empty($lce))) {
        return;
    }
    delete_option('cx_c9f1a6384b1c466d4612f513bd8e13ea');
    if (function_exists('curl_init')) {
        $d = cx_current_page_url();
        $data = cx_curl_post("http://www.screets.com/api/v2/", array('c' => $c, 'p' => 'CX', 'd' => $d, 'v' => CX_VERSION));
        $r = explode("\n", $data);
        $hash = array_shift($r);
        if ($hash == 'c9f1a6384b1c466d4612f513bd8e13ea') {
            update_option('cx_c9f1a6384b1c466d4612f513bd8e13ea', $r[0]);
        } elseif (!empty($r[0])) {
            update_option('cx_error', $r[0]);
            delete_option('cx_c9f1a6384b1c466d4612f513bd8e13ea');
        } else {
            // Catch error
            update_option('cx_error', cx_('Q1ggY2FuJ3QgYWN0aXZhdGUgaXRzZWxmIG5vdy4gWW91IHdpbGwgd2FudCB0byBzZW5kIGVycm9yIG1lc3NhZ2UgdG8gdXM6IDxhIGhyZWY9Im1haWx0bzpzdXBwb3J0QHNjcmVldHMuY29tIj5zdXBwb3J0QHNjcmVldHMuY29tPC9hPi4gSWYgeW91IGNyZWF0ZSB0ZW1wb3JhcnkgYWRtaW4gdXNlciwgdGhlbiB3ZSBjYW4gYWN0aXZhdGUgbGljZW5zZSBmb3IgeW91IQ==') . '<p><small><strong>ERROR MESSAGE:</strong> ' . print_r($data, 1) . '</small></p>');
        }
    } else {
        update_option('cx_error', cx_('Y1VSTCBpcyA8c3Ryb25nPk5PVDwvc3Ryb25nPiBpbnN0YWxsZWQgaW4geW91ciBQSFAgaW5zdGFsbGF0aW9uLiBZb3Ugd2lsbCB3YW50IHRvIGZvbGxvdyA8YSBocmVmPSJodHRwOi8vc3RhY2tvdmVyZmxvdy5jb20vcXVlc3Rpb25zLzEzNDcxNDYvaG93LXRvLWVuYWJsZS1jdXJsLWluLXBocC14YW1wcCIgdGFyZ2V0PSJfYmxhbmsiPm9uZSBvZiB0aG9zZSB0dXRvcmlhbHM8L2E+IHRvIGVuYWJsZSBjVVJMIGxpYnJhcnk='));
    }
}
コード例 #2
0
 /**
  * Init Screets Chat X when WordPress Initialises
  *
  * @access public
  * @return void
  */
 function init()
 {
     // Before init action
     do_action('before_cx_init');
     // Check if Woocommerce installed
     if (function_exists('is_woocommerce')) {
         define('CX_WC_INSTALLED', true);
     }
     // Some user info
     $this->current_page = cx_current_page_url();
     $this->ip = cx_ip_address();
     // User is operator?
     if (current_user_can('answer_visitors')) {
         define('CX_OP', true);
         // User is visitor?
     } else {
         define('CX_VISITOR', true);
     }
     if (!is_admin() || defined('DOING_AJAX')) {
         add_action('wp_enqueue_scripts', array(&$this, 'frontend_scripts'));
         add_action('wp_print_scripts', array($this, 'check_jquery'), 25);
     }
     // Create options object
     $this->option = new CX_options(__FILE__);
     // Get options set
     require CX_PATH . '/core/options/options.php';
     // Create options page
     $this->option->add_options_page(array('menu_title' => __('Settings', 'cx'), 'parent' => 'chat_x'), $cx_opts_set);
     // Get all options
     $this->opts = $this->option->get_options();
     // Ajax requests
     $ajax_prefix = !empty($this->opts['faster_ajax']) ? 'cx_' : 'wp_';
     add_action($ajax_prefix . 'ajax_cx_ajax_callback', 'cx_ajax_callback');
     add_action($ajax_prefix . 'ajax_nopriv_cx_ajax_callback', 'cx_ajax_callback');
     // WPML support (updates opts)
     if (function_exists('icl_register_string')) {
         $this->WPML($cx_opts_set);
     }
     // Save user info
     if (is_user_logged_in()) {
         global $current_user;
         // Get currently logged user info
         get_currentuserinfo();
         $this->user = $current_user;
         // Visitor info
     } else {
         $visitor_id = $this->session->get('visitor_id');
         // Create new unique ID
         if (empty($visitor_id)) {
             $visitor_id = uniqid(rand(), false);
             // Save id into the session
             $this->session->set('visitor_id', $visitor_id);
         }
         $this->user = (object) array('ID' => $visitor_id, 'display_name' => null, 'user_email' => null);
     }
     // Register Visitors post type when default AJAX base is enabled
     /*if( $this->opts['app'] == 'none' ) {
     
     			$labels = array(
     				'name'                => _x( 'Visitors', 'Post Type General Name', 'cx' ),
     				'singular_name'       => _x( 'Visitor', 'Post Type Singular Name', 'cx' ),
     				'menu_name'           => __( 'Visitor', 'cx' ),
     				'parent_item_colon'   => __( 'Parent Visitor:', 'cx' ),
     				'all_items'           => __( 'All Visitors', 'cx' ),
     				'view_item'           => __( 'View Visitor', 'cx' ),
     				'add_new_item'        => __( 'Add New Visitor', 'cx' ),
     				'add_new'             => __( 'New Visitor', 'cx' ),
     				'edit_item'           => __( 'Edit Visitor', 'cx' ),
     				'update_item'         => __( 'Update Visitor', 'cx' ),
     				'search_items'        => __( 'Search visitors', 'cx' ),
     				'not_found'           => __( 'No visitors found', 'cx' ),
     				'not_found_in_trash'  => __( 'No visitors found in Trash', 'cx' ),
     			);
     			$args = array(
     				'labels'              => $labels,
     				'supports'            => array( 'title', 'custom-fields' ),
     				'hierarchical'        => false,
     				'public'              => false,
     				'show_ui'             => true,
     				'show_in_menu'        => false,
     				'show_in_nav_menus'   => false,
     				'show_in_admin_bar'   => false,
     				'menu_position'       => 60,
     				'menu_icon'           => '',
     				'can_export'          => true,
     				'has_archive'         => true,
     				'exclude_from_search' => true,
     				'publicly_queryable'  => true,
     				'capability_type'     => 'page',
     				'capabilities' 		  => array(
     					// 'create_posts' => false
     				)
     			);
     			register_post_type( 'cx_visitor', $args );
     
     		}*/
     // Register Offline Messages post type
     $labels = array('name' => _x('Offline Messages', 'Post Type General Name', 'cx'), 'singular_name' => _x('Offline Message', 'Post Type Singular Name', 'cx'), 'menu_name' => __('Offline Message', 'cx'), 'parent_item_colon' => __('Parent Offline Message:', 'cx'), 'all_items' => __('All Offline Messages', 'cx'), 'view_item' => __('View Offline Message', 'cx'), 'add_new_item' => __('Add New Offline Message', 'cx'), 'add_new' => __('New Offline Message', 'cx'), 'edit_item' => __('Edit Offline Message', 'cx'), 'update_item' => __('Update Offline Message', 'cx'), 'search_items' => __('Search offline message', 'cx'), 'not_found' => __('No offline message found', 'cx'), 'not_found_in_trash' => __('No offline message found in Trash', 'cx'));
     $args = array('labels' => $labels, 'supports' => array('title'), 'hierarchical' => false, 'public' => false, 'show_ui' => true, 'show_in_menu' => false, 'show_in_nav_menus' => false, 'show_in_admin_bar' => false, 'menu_position' => 60, 'menu_icon' => '', 'can_export' => true, 'has_archive' => false, 'exclude_from_search' => true, 'publicly_queryable' => false, 'rewrite' => false, 'capability_type' => 'page', 'capabilities' => array());
     register_post_type('cx_offline_msg', $args);
     // Predefined Messages post type
     /*$labels = array(
     			'name'                => _x( 'Predifined Messages', 'Post Type General Name', 'cx' ),
     			'singular_name'       => _x( 'Predefined Message', 'Post Type Singular Name', 'cx' ),
     			'menu_name'           => __( 'Predefined Message', 'cx' ),
     			'parent_item_colon'   => __( 'Parent Predefined Message:', 'cx' ),
     			'all_items'           => __( 'All Predefined Messages', 'cx' ),
     			'view_item'           => __( 'View Predefined Message', 'cx' ),
     			'add_new_item'        => __( 'Add New Predefined Message', 'cx' ),
     			'add_new'             => __( 'New Predefined Message', 'cx' ),
     			'edit_item'           => __( 'Edit Predefined Message', 'cx' ),
     			'update_item'         => __( 'Update Predefined Message', 'cx' ),
     			'search_items'        => __( 'Search predefined message', 'cx' ),
     			'not_found'           => __( 'No predefined message found', 'cx' ),
     			'not_found_in_trash'  => __( 'No predefined message found in Trash', 'cx' ),
     		);
     		$args = array(
     			'labels'              => $labels,
     			'supports'            => array( 'title', 'editor' ),
     			'hierarchical'        => false,
     			'public'              => false,
     			'show_ui'             => true,
     			'show_in_menu'        => false,
     			'show_in_nav_menus'   => false,
     			'show_in_admin_bar'   => false,
     			'menu_position'       => 60,
     			'menu_icon'           => '',
     			'can_export'          => true,
     			'has_archive'         => true,
     			'exclude_from_search' => true,
     			'publicly_queryable'  => true,
     			'capability_type'     => 'page',
     			'capabilities' 		  => array(
     				// 'create_posts' => false
     			)
     		);
     		register_post_type( 'cx_predefined_msg', $args );*/
     // Add operator name to user fields
     if (defined('CX_OP')) {
         add_action('show_user_profile', array(&$this, 'xtra_profile_fields'), 10);
         add_action('edit_user_profile', array(&$this, 'xtra_profile_fields'), 10);
         add_action('personal_options_update', array(&$this, 'save_xtra_profile_fields'));
         add_action('edit_user_profile_update', array(&$this, 'save_xtra_profile_fields'));
     }
     // Add custom css
     if (!empty($this->opts['custom_css']) || @$this->opts['avatar_size'] != 30) {
         add_action('wp_footer', array(&$this, 'custom_css'));
     }
     // Render chat box
     add_action('wp_footer', array(&$this, 'display_chatbox'));
     // Shortcodes
     add_shortcode('cx_btn', 'cx_shortcode_open_chatbox');
     // Check updates
     $this->update();
     // Initialization action
     do_action('cx_init');
 }