function remote_login($user_login, $user) { $user_login = get_chatwee_user_login(); $chatId = get_option('chatwee-settings-group[clientid]'); $clientKey = get_option('chatwee-settings-group[keyapi]'); $isAdmin = 0; if (is_super_admin($user->ID) || checkIfUserIsAdmin($user->ID) || belong_to_moderator_group($user->ID)) { $isAdmin = 1; } $ismobile = check_user_agent('mobile') == true ? 1 : 0; $ip = get_the_user_ip(); $avatar = get_avatar_url_for_chatwee($user->ID); if (isset($_COOKIE["chch-SI"])) { remote_logout(); } if (isset($_SESSION['chatwee'][$user_login])) { $previousSessionId = $_SESSION['chatwee'][$user_login]; } else { if (isset($_COOKIE["chch-PSI"])) { $previousSessionId = $_COOKIE["chch-PSI"]; } else { $previousSessionId = null; } } $url = "http://chatwee-api.com/api/remotelogin?chatId=" . $chatId . "&clientKey=" . $clientKey . "&login="******"&isAdmin=" . $isAdmin . "&ipAddress=" . $ip . "&avatar=" . $avatar . "&isMobile=" . $ismobile . "&previousSessionId=" . $previousSessionId; $url = str_replace(' ', '%20', $url); $response = get_response($url); $sessionArray = json_decode($response); if ($sessionArray->errorCode) { update_option('chatwee-settings-group[ssoiserror]', $sessionArray->errorMessage); } else { update_option('chatwee-settings-group[ssoiserror]', ''); } $sessionId = $sessionArray->sessionId; $fullDomain = $_SERVER["HTTP_HOST"]; $isNumericDomain = preg_match('/\\d|"."/', $fullDomain); if ($isNumericDomain || !get_option('chatwee-settings-group[loginallsubdomains]')) { $CookieDomain = $fullDomain; } else { $hostChunks = explode(".", $fullDomain); $hostChunks = array_slice($hostChunks, -2); $CookieDomain = "." . implode(".", $hostChunks); } setcookie("chch-SI", $sessionId, time() + 2592000, "/", $CookieDomain); $_SESSION['chatwee'][$user_login] = $_SESSION['chatwee'][$user_login] == '' ? $sessionId : $_SESSION['chatwee'][$user_login]; }
function get_post_likes($post_id = null) { global $post; $user_ip = get_the_user_ip(); $the_post = $post_id ? get_post($post_id) : $post; $likes = $the_post->post_likes; if (!is_array($likes)) { $likes = array(); } $output = array('liked' => in_array($user_ip, $likes), 'count' => count($likes)); return $output; }
function user_like() { $key = 'user_likes'; if ($_POST['type'] == 'music') { $key = 'user_likes_music'; } //delete_post_meta($_POST['product_id'],'user_likes'); $old = get_post_meta($_POST['product_id'], $key); if (!is_array($old)) { $old = array(); } $old = $old[0]; $old[get_current_user_id() . '-' . get_the_user_ip()] = array('User_ID' => get_current_user_id(), 'IP' => get_the_user_ip()); update_post_meta($_POST['product_id'], $key, $old); $data = get_post_meta($_POST['product_id'], $key); echo '{"status":"Ok","total":"' . sizeof($data[0]) . '"}'; }
<?php include_once $_SERVER['DOCUMENT_ROOT'] . 'wordpress/wp-config.php'; include_once $_SERVER['DOCUMENT_ROOT'] . 'wordpress/wp-content/plugins/fjn-poll/fjn-poll.php'; header('Content-Type: text/html; charset=utf-8'); get_header(); $post_id = $_GET['poll']; $vote = $_GET['vote']; $user_id = get_the_user_ip(); if (user_check($user_id, $post_id)) { echo "<script>alert('You have already voted, So your vote is not registered. You can just see the Results');</script>"; global $wpdb; $findVotes = $wpdb->get_var($wpdb->prepare("\n\t\t\t\t\tSELECT all_votes \n\t\t\t\t\tFROM wp_polls \n\t\t\t\t\tWHERE poll_id = %d\n\t\t\t\t", $post_id)); $str1 = get_post_field('post_content', $post_id); $choices = explode('-', $str1); ?> <h2> Results: <h3><?php for ($i = 0; $i < count($choices); $i++) { $result = $wpdb->get_results("SELECT ans_title,votes FROM wp_answers WHERE poll_id={$post_id} AND ans_id={$i}"); ?> <table border="1" style="width:70%"> <tr> <td> <?php echo $result[0]->ans_title; ?> </td> <td><?php echo 100 * round($result[0]->votes / $findVotes, 4); ?> </td>