Changeset 991121
- Timestamp:
- 09/16/2014 02:45:45 PM (11 years ago)
- Location:
- because/trunk
- Files:
-
- 2 edited
-
README.txt (modified) (1 diff)
-
social-polling.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
because/trunk/README.txt
r987352 r991121 7 7 Tested up to: 4.0 8 8 <<<<<<< .mine 9 Stable tag: 1.2. 89 Stable tag: 1.2.9 10 10 ======= 11 Stable tag: 1.2. 811 Stable tag: 1.2.9 12 12 >>>>>>> .r969865 13 13 License: GPLv2 or later -
because/trunk/social-polling.php
r987357 r991121 108 108 */ 109 109 110 register_activation_hook( __FILE__, array( 'Social_Polling', 'activate' ) ); 111 112 register_deactivation_hook( __FILE__, array( 'Social_Polling', 'deactivate' ) ); 113 114 115 116 117 function social_poll_activate() { 118 ob_start(); 119 //Site Name 120 $site_name = urlencode(get_option ('blogname')); 121 //Site Url 122 $site_url = urlencode(get_option ('siteurl')); 123 //Site Description 124 $site_description = urlencode(get_option('blogdescription')); 125 126 // Get cURL resource 127 $curl = curl_init(); 128 // Set some options - we are passing in a useragent too here 129 curl_setopt_array($curl, array( 130 CURLOPT_RETURNTRANSFER => 1, 131 CURLOPT_URL => 'http://www.teambecause.com/pluginactivated.php?sitename='.$site_name.'&site_url='.$site_url.'&site_description='.$site_description, 132 CURLOPT_USERAGENT => 'Codular Sample cURL Request' 133 )); 134 // Send the request & save response to $resp 135 $resp = curl_exec($curl); 136 // Close request to clear up some resources 137 curl_close($curl); 138 139 //exit; 140 141 ob_end_clean(); 142 }//social_poll_activate 143 register_activation_hook( __FILE__, 'social_poll_activate' ); 144 145 146 147 //COMEBACKVERB 148 149 register_activation_hook( __FILE__, array( 'spComments', 'activate' ) ); 150 151 register_deactivation_hook( __FILE__, array( 'spComments', 'deactivate' ) ); 152 110 // SETTINGS 111 define('BECAUSE_ADMIN_SERVER_URL', 'http://108.174.62.50/because/symfony/web/api/ <replace with your own location> 112 action'); 113 define('BECAUSE_ADMIN_SECRET_TOKEN_NAME', 'secretToken'); 114 define('BECAUSE_ADMIN_SECRET_TOKEN_VALUE', 'X-Secret-Token'); 115 register_activation_hook( __FILE__, 'because_plugin_activate' ); 116 function because_plugin_activate(){ 117 $data = get_wp_data(); 118 $data['isActivation'] = '1'; 119 send_statistic_data($data); 120 } 121 register_deactivation_hook( __FILE__, 'because_plugin_deactivate' ); 122 function because_plugin_deactivate() 123 { 124 $data = get_wp_data(); 125 $data['isActivation'] = '0'; 126 send_statistic_data($data);} 127 function get_wp_data(){ 128 $site_url = get_site_url(); 129 $site_name = get_bloginfo('name'); 130 $site_ip_addr = get_ip(); 131 $data_arr = array( 132 'siteIpAddress' => $site_ip_addr, 133 'siteName' => $site_name, 134 'siteUrl' => $site_url 135 ); 136 return $data_arr; 137 } 138 function send_statistic_data($data) 139 { 140 try { 141 $ch = curl_init(); 142 curl_setopt($ch, CURLOPT_URL, BECAUSE_ADMIN_SERVER_URL); 143 curl_setopt($ch, CURLOPT_POST, 1); 144 $header = array(BECAUSE_ADMIN_SECRET_TOKEN_NAME.': ' . 145 BECAUSE_ADMIN_SECRET_TOKEN_VALUE); 146 curl_setopt($ch, CURLOPT_HTTPHEADER, $header); 147 curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 148 curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); 149 $response = curl_exec ($ch); 150 $error = curl_error($ch); 151 curl_close ($ch); 152 }catch (Exception $error) { 153 $this->debug(__METHOD__, 'CURL error: ' . $error); 154 return $response; 155 } 156 } 157 158 function get_ip() 159 { 160 161 if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown")) 162 $ip = getenv("HTTP_CLIENT_IP"); 163 else if (getenv("HTTP_X_FORWARDED_FOR") && 164 strcasecmp(getenv("HTTP_X_FORWARDED_FOR"), "unknown")) 165 $ip = getenv("HTTP_X_FORWARDED_FOR"); 166 else if (getenv("REMOTE_ADDR") && strcasecmp(getenv("REMOTE_ADDR"), "unknown")) 167 $ip = getenv("REMOTE_ADDR"); 168 else if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && 169 strcasecmp($_SERVER['REMOTE_ADDR'], "unknown")) 170 $ip = $_SERVER['REMOTE_ADDR']; 171 else 172 $ip = "unknown"; 173 return($ip); 174 } 153 175 /* 154 176
Note: See TracChangeset
for help on using the changeset viewer.