Plugin Directory

Changeset 2272018


Ignore:
Timestamp:
03/31/2020 07:44:22 PM (6 years ago)
Author:
proxymis
Message:
  • CURL alternative to hosting plans without 'file_get_contents' enabled
Location:
html5-chat/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • html5-chat/trunk/index.php

    r2249006 r2272018  
    3333     */
    3434    static function pluginActivated() {
     35
    3536        $user = wp_get_current_user();
    3637        $roles = $user->roles;
     
    3940        $username = $user->user_login;;
    4041        $domain = get_site_url(null, '', '');
    41 
    4242        if (!$domain) {
    4343            $domain = get_home_url(null, '', '');
     
    5151
    5252        $params = array (
    53                 'a'                 =>'createAccountWP',
    54                 'username'          =>$username,
    55                 'email'             =>$email,
    56                 'isAdmin'           =>$isAdmin,
    57                 'url'               =>$domain,
    58                 'wp_register_url'   =>$wp_register_url,
    59                 'wp_login_url'      =>$wp_login_url);
     53            'a'                 =>'createAccountWP',
     54            'username'          =>$username,
     55            'email'             =>$email,
     56            'isAdmin'           =>$isAdmin,
     57            'url'               =>$domain,
     58            'wp_register_url'   =>$wp_register_url,
     59            'wp_login_url'      =>$wp_login_url);
     60
    6061        $query = http_build_query ($params);
    6162        $contextData = array (
     
    6465            'content'=> $query
    6566        );
    66         $context = stream_context_create (array ( 'http' => $contextData ));
    67         $result =  file_get_contents (self::$registerAccountUrl, false, $context);
     67
     68        function file_get_contents2($url, $data){
     69            $ch = curl_init();
     70            curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
     71            curl_setopt($ch, CURLOPT_HEADER, 0);
     72            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     73            curl_setopt($ch, CURLOPT_URL, $url);
     74            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
     75            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 3);
     76            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
     77            curl_setopt($ch, CURLOPT_POST, true);
     78            curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
     79            $res = curl_exec($ch);
     80            curl_close($ch);
     81            return $res;
     82        }
     83        if( !ini_get('allow_url_fopen') ) {
     84            $result = file_get_contents2(self::$registerAccountUrl, $params);
     85        } else {
     86            $context = stream_context_create (array ( 'http' => $contextData ));
     87            $result =  file_get_contents (self::$registerAccountUrl, false, $context);
     88        }
    6889        set_transient( self::$noticeName, $result, 5 );
    6990    }
  • html5-chat/trunk/readme.txt

    r2249006 r2272018  
    1919== Installation ==
    2020
    21 * activate the plugin
     21* just activate the plugin
    2222* insert the [HTML5CHAT width=100% height=640px] short code into your page or post
    2323* you can configure your chat look&feel through your "configure chat" link
Note: See TracChangeset for help on using the changeset viewer.