/** * Reports a count to the StatHat API. * * @param int $count * The count to report. */ public function reportCount($count) { $statName = $this->prefix . $this->statNames; if ($this->isProduction) { stathat_ez_count($this->ezkey, $statName, $count); } }
/** * firstDelimiterLyrics function. * * @access public * @param mixed $w * @param mixed $query * @param mixed $settings * @param mixed $db * @param mixed $update_in_progress * @return void */ function firstDelimiterLyrics($w, $query, $settings, $db, $update_in_progress) { $words = explode('▹', $query); $kind = $words[0]; $all_playlists = $settings->all_playlists; $is_alfred_playlist_active = $settings->is_alfred_playlist_active; $radio_number_tracks = $settings->radio_number_tracks; $now_playing_notifications = $settings->now_playing_notifications; $max_results = $settings->max_results; $alfred_playlist_uri = $settings->alfred_playlist_uri; $alfred_playlist_name = $settings->alfred_playlist_name; $country_code = $settings->country_code; $last_check_update_time = $settings->last_check_update_time; $oauth_client_id = $settings->oauth_client_id; $oauth_client_secret = $settings->oauth_client_secret; $oauth_redirect_uri = $settings->oauth_redirect_uri; $oauth_access_token = $settings->oauth_access_token; $oauth_expires = $settings->oauth_expires; $oauth_refresh_token = $settings->oauth_refresh_token; $display_name = $settings->display_name; $userid = $settings->userid; $echonest_api_key = $settings->echonest_api_key; if (substr_count($query, '∙') == 2) { // // Search Lyrics // $tmp = $words[1]; $words = explode('∙', $tmp); $track_uri = $words[0]; $artist_name = $words[1]; $track_name = $words[2]; list($lyrics_url, $lyrics) = getLyrics($w, $artist_name, $track_name); if ($userid != 'vdesabou') { stathat_ez_count('AlfredSpotifyMiniPlayer', 'lyrics', 1); } if ($lyrics_url != false) { $w->result(null, serialize(array('', '', '', '', '', '', 'Open▹' . $lyrics_url, '', '', '', '', '', '', '', '', '')), 'See lyrics for ' . $track_name . ' by ' . $artist_name . ' online', "This will open your default browser", './images/lyrics.png', 'yes', null, ''); $track_artwork = getTrackOrAlbumArtwork($w, $track_uri, false); $wrapped = wordwrap($lyrics, 70, "\n", false); $lyrics_sentances = explode("\n", $wrapped); for ($i = 0; $i < count($lyrics_sentances); $i++) { $w->result(null, '', $lyrics_sentances[$i], '', $track_artwork, 'no', null, ''); } } else { $w->result(null, 'help', "No lyrics found!", "", './images/warning.png', 'no', null, ''); echo $w->toxml(); return; } } }
function register_usage($portalID, $appID, $screenId = 169, $action = "", $hs_settings = "") { if (!is_array($hs_settings)) { $hs_settings = array(); $hs_settings = get_option('hs_settings'); } if ($hs_settings["hs_portal"] != "" && $hs_settings["hs_appdomain"] != "") { $logging_url = 'http://usagetracking.hubapi.com/UsageTracker/addActivity'; $logging_url .= '?portalId=' . $portalID; $logging_url .= '&appId=' . $appID; $logging_url .= '&screenId=' . $screenId; if ($action != "") { $logging_url .= '&action=' . $action; // Register with StatHat $replace_these = array('+', '%2F'); $stathat_key = 'HSWP-' . str_replace($replace_these, '-', $action); stathat_ez_count("{$stathat_key}", 1); // Count if action is present } wp_remote_fopen($logging_url); } }
/** * getArtistArtwork function. * * @access public * @param mixed $w * @param mixed $artist * @param mixed $fetchIfNotPresent * @return void */ function getArtistArtwork($w, $artist, $fetchIfNotPresent = false, $fetchLater = false, $isLaterFetch = false) { $parsedArtist = urlencode(escapeQuery($artist)); if (!file_exists($w->data() . "/artwork")) { exec("mkdir '" . $w->data() . "/artwork'"); } $currentArtwork = $w->data() . "/artwork/" . hash('md5', $parsedArtist . ".png") . "/" . "{$parsedArtist}.png"; $artwork = ""; // if ($fetchLater == true) { if (!is_file($currentArtwork)) { return array(false, $currentArtwork); } else { return array(true, $currentArtwork); } // always return currentArtwork return $currentArtwork; } if (!is_file($currentArtwork) || is_file($currentArtwork) && filesize($currentArtwork) == 0) { if ($fetchIfNotPresent == true || is_file($currentArtwork) && filesize($currentArtwork) == 0) { $artwork = getArtistArtworkURL($w, $artist); // if return 0, it is a 404 error, no need to fetch if (!empty($artwork) || is_numeric($artwork) && $artwork != 0) { if (!file_exists($w->data() . "/artwork/" . hash('md5', $parsedArtist . ".png"))) { exec("mkdir '" . $w->data() . "/artwork/" . hash('md5', $parsedArtist . ".png") . "'"); } $fp = fopen($currentArtwork, 'w+'); $options = array(CURLOPT_FILE => $fp); $w->request("{$artwork}", $options); stathat_ez_count('AlfredSpotifyMiniPlayer', 'artworks', 1); if ($isLaterFetch == true) { return true; } } else { if ($isLaterFetch == true) { if (!file_exists($w->data() . "/artwork/" . hash('md5', $parsedArtist . ".png"))) { exec("mkdir '" . $w->data() . "/artwork/" . hash('md5', $parsedArtist . ".png") . "'"); } copy('./images/artists.png', $currentArtwork); return false; } else { return "./images/artists.png"; } } } else { if ($isLaterFetch == true) { if (!file_exists($w->data() . "/artwork/" . hash('md5', $parsedArtist . ".png"))) { exec("mkdir '" . $w->data() . "/artwork/" . hash('md5', $parsedArtist . ".png") . "'"); } copy('./images/artists.png', $currentArtwork); return false; } else { return "./images/artists.png"; } } } else { if (filesize($currentArtwork) == 0) { if ($isLaterFetch == true) { if (!file_exists($w->data() . "/artwork/" . hash('md5', $parsedArtist . ".png"))) { exec("mkdir '" . $w->data() . "/artwork/" . hash('md5', $parsedArtist . ".png") . "'"); } copy('./images/artists.png', $currentArtwork); return false; } else { return "./images/artists.png"; } } } if (is_numeric($artwork) && $artwork == 0) { if ($isLaterFetch == true) { if (!file_exists($w->data() . "/artwork/" . hash('md5', $parsedArtist . ".png"))) { exec("mkdir '" . $w->data() . "/artwork/" . hash('md5', $parsedArtist . ".png") . "'"); } copy('./images/artists.png', $currentArtwork); return false; } else { return "./images/artists.png"; } } else { return $currentArtwork; } }
return; } updateLibrary($w); if ($userid != 'vdesabou') { stathat_ez_count('AlfredSpotifyMiniPlayer', 'update library', 1); } return; } else { if ($other_action == "refresh_library") { if (file_exists($w->data() . '/update_library_in_progress')) { displayNotificationWithArtwork("Cannot modify library while update is in progress", './images/warning.png', 'Error!'); return; } refreshLibrary($w); if ($userid != 'vdesabou') { stathat_ez_count('AlfredSpotifyMiniPlayer', 'update library', 1); } return; } } } } } } } } } } } } }
function hs_analytics_insert() { global $current_user; wp_reset_query(); get_currentuserinfo(); $hs_settings = array(); $hs_settings = get_option('hs_settings'); if ($hs_settings["hs_portal"] != "") { // Identify the current user if logged in if ($current_user->user_email) { $hs_identify_name = $current_user->user_login; $hs_identify_email = $current_user->user_email; $hs_identify_id = md5($current_user->user_email); } else { $commenter = wp_get_current_commenter(); if ($commenter['comment_author_email']) { $hs_identify_name = $commenter['comment_author']; $hs_identify_email = $commenter['comment_author_email']; $hs_identify_id = md5($commenter['comment_author_email']); } } if (isset($hs_identify_email)) { echo "\n" . '<!-- DO NOT COPY THIS SNIPPET! -- HubSpot User Identification Code -->' . "\n"; echo '<script type="text/javascript">' . "\n"; echo "(function(d,w) {\n"; // Wrap `identify` call in hubspotutk check to help prevent accidental copy-paste if (isset($_COOKIE['hubspotutk'])) { echo "var match = d.cookie.match('(^|;) ?hubspotutk=([^;]*)(;|\$)');\n"; echo "if (match && match[2] == \"" . $_COOKIE['hubspotutk'] . "\") {\n"; } echo "w._hsq = w._hsq || [];\n"; echo "w._hsq.push([\"identify\", {\n"; echo " \"email\" : \"" . $hs_identify_email . "\",\n"; echo " \"name\" : \"" . $hs_identify_name . "\",\n"; echo " \"id\" : \"" . $hs_identify_id . "\"\n"; echo "}]);\n"; if (isset($_COOKIE['hubspotutk'])) { echo "}\n"; } echo "})(document, window);\n"; echo '</script>' . "\n"; echo '<!-- End of HubSpot User Identification Code -- DO NOT COPY THIS SNIPPET! -->' . "\n"; stathat_ez_count('HSWP-identified-user', 1); } echo "\n" . '<!-- Start of Async HubSpot Analytics Code for WordPress v' . HUBSPOT_PLUGIN_VERSION . ' -->' . "\n"; echo '<script type="text/javascript">' . "\n"; echo 'var _hsq = _hsq || [];' . "\n"; // Pass along the correct content-type if (is_single()) { echo '_hsq.push(["setContentType", "blog-post"]);' . "\n"; } else { if (is_archive() || is_search()) { echo '_hsq.push(["setContentType", "listing-page"]);' . "\n"; } else { echo '_hsq.push(["setContentType", "standard-page"]);' . "\n"; } } echo '(function(d,s,i,r) {' . "\n"; echo ' if (d.getElementById(i)){return;}' . "\n"; echo ' var n = d.createElement(s),e = document.getElementsByTagName(s)[0];' . "\n"; echo ' n.id=i;n.src = \'//js.hs-analytics.net/analytics/\'+(Math.ceil(new Date()/r)*r)+\'/' . trim($hs_settings["hs_portal"]) . '.js\';' . "\n"; echo ' e.parentNode.insertBefore(n, e);' . "\n"; echo '})(document, "script", "hs-analytics", 300000);' . "\n"; echo '</script>' . "\n"; echo '<!-- End of Async HubSpot Analytics Code -->' . "\n"; } }