Пример #1
0
/**
 * This function will escape the user inputed data. It will check to see if magic quotes is on.
 * If it is not on, it will manually escape(using mysql_real_escape_string()) all the requests and return it.
 * Argument : $param_array - [OPTIONAL] The array that must be escaped. If empty, the function uses $_POST + $_GET
 *			  $ignore_magic_quote_setting - [OPTIONAL] If set to true, this will escape the given array no matter what the get_magic_quotes_gpc() returns. Defaults to 'true'
 * Return	: The escaped format of the array.
 * Usage 	: $PARAM = unescapeQuery();
 *			  $QUERY = escapeQuery($PARAM,true);
 */
function escapeQuery($param_array = array(), $ignore_magic_quote_setting = false)
{
    $QUERY = array();
    if (!$param_array) {
        $param_array = $_POST + $_GET;
    }
    //Don't use $_REQUEST - it has cookie/session info in it.
    if (!$ignore_magic_quote_setting and get_magic_quotes_gpc()) {
        return $param_array;
    }
    //If Magic quotes is enabled, just return the data - it is already escaped.
    while (list($key, $value) = each($param_array)) {
        if (is_array($value)) {
            //Escape Arrays recursively
            $QUERY[$key] = escapeQuery($value, $ignore_magic_quote_setting);
            //:RECURSION:
        } else {
            if ($GLOBALS['sql']) {
                $value = $GLOBALS['sql']->escape($value);
            } else {
                $value = addslashes($value);
            }
            $QUERY[$key] = htmlspecialchars($value);
        }
    }
    return $QUERY;
}
Пример #2
0
/**
 * thirdDelimiterBrowse function.
 *
 * @access public
 * @param mixed $w
 * @param mixed $query
 * @param mixed $settings
 * @param mixed $db
 * @param mixed $update_in_progress
 * @return void
 */
function thirdDelimiterBrowse($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;
    $country = $words[1];
    $category = $words[2];
    try {
        $offsetCategoryPlaylists = 0;
        $limitCategoryPlaylists = 50;
        $api = getSpotifyWebAPI($w);
        do {
            // refresh api
            $api = getSpotifyWebAPI($w, $api);
            $listPlaylists = $api->getCategoryPlaylists($category, array('country' => $country, 'limit' => $limitCategoryPlaylists, 'offset' => $offsetCategoryPlaylists));
            $subtitle = "Launch Playlist";
            $playlists = $listPlaylists->playlists;
            $items = $playlists->items;
            foreach ($items as $playlist) {
                $w->result(null, '', "🎵" . escapeQuery($playlist->name), "by " . $playlist->owner->id . " ● " . $playlist->tracks->total . " tracks", getPlaylistArtwork($w, $playlist->uri, false), 'no', null, "Online Playlist▹" . $playlist->uri . '∙' . escapeQuery($playlist->name) . "▹");
            }
            $offsetCategoryPlaylists += $limitCategoryPlaylists;
        } while ($offsetCategoryPlaylists < $listPlaylists->playlists->total);
    } catch (SpotifyWebAPI\SpotifyWebAPIException $e) {
        $w->result(null, 'help', "Exception occurred", "" . $e->getMessage(), './images/warning.png', 'no', null, '');
        echo $w->toxml();
        return;
    }
}
Пример #3
0
/**
 * handleSpotifyWebAPIException function.
 *
 * @access public
 * @param mixed $w
 * @param mixed $e
 * @return void
 */
function handleSpotifyWebAPIException($w, $e)
{
    if (file_exists($w->data() . '/update_library_in_progress')) {
        deleteTheFile($w->data() . '/update_library_in_progress');
    }
    // remove the new library (it failed)
    if (file_exists($w->data() . "/library_new.db")) {
        deleteTheFile($w->data() . '/library_new.db');
    }
    // set back old library
    if (file_exists($w->data() . '/library_old.db')) {
        rename($w->data() . '/library_old.db', $w->data() . '/library.db');
    }
    displayNotificationWithArtwork('Web API Exception: ' . $e->getCode() . ' - ' . $e->getMessage() . ' use spot_mini_debug command', './images/warning.png', 'Error!');
    exec("osascript -e 'tell application \"Alfred 2\" to search \"spot_mini_debug Web API Exception: " . escapeQuery($e->getMessage()) . "\"'");
    exit;
}
Пример #4
0
     $query = array_pop($history);
     // pop twice
     $query = array_pop($history);
     $w->write($history, 'history.json');
     exec("osascript -e 'tell application \"Alfred 2\" to search \"spot_mini {$query}\"'");
     return;
 } else {
     if ($other_action == "lookup_artist") {
         if (!$w->internet()) {
             displayNotificationWithArtwork("No internet connection", './images/warning.png', 'Error!');
             return;
         }
         if ($artist_uri == "") {
             $artist_uri = getArtistUriFromTrack($w, $track_uri);
         }
         exec("osascript -e 'tell application \"Alfred 2\" to search \"spot_mini Onlineâ–¹" . $artist_uri . "@" . escapeQuery($artist_name) . 'â–¹' . "\"'");
         if ($userid != 'vdesabou') {
             stathat_ez_count('AlfredSpotifyMiniPlayer', 'lookup online', 1);
         }
         return;
     } else {
         if ($other_action == "playartist") {
             $artist_artwork_path = getArtistArtwork($w, $artist_uri, $artist_name, true);
             $mopidy_arg = "";
             if ($use_mopidy) {
                 $mopidy_arg = "MOPIDY";
             }
             exec("./src/spotify_mini_player_notifications.ksh -d \"" . $w->data() . "\" -a start -m \"" . $mopidy_arg . "\"  >> \"" . $w->cache() . "/action.log\" 2>&1 & ");
             if (!$use_mopidy) {
                 exec("./src/track_info.ksh 2>&1", $retArr, $retVal);
                 if ($retVal != 0) {
Пример #5
0
    //If the 'configuration.php' file is found, use that
    require $rel . "configuration.php";
    if ($rel == '') {
        $config['site_folder'] = realpath('.');
    } else {
        $config['site_folder'] = realpath($rel);
    }
    $config['site_relative_path'] = $rel;
} else {
    require $iframe_folder . 'configuration.php';
    $config['site_folder'] = $config['iframe_folder'];
    $config['site_relative_path'] = '';
}
$config['iframe_folder'] = $iframe_folder;
require $config['iframe_folder'] . "includes/functions.php";
// This is $_REQUERST without the problems asssociated with magic quotes
$PARAM = unescapeQuery();
$QUERY = escapeQuery($PARAM, true);
if (!isset($QUERY['error'])) {
    $QUERY['error'] = '';
    $PARAM['error'] = '';
}
if (!isset($QUERY['success'])) {
    $QUERY['success'] = '';
    $PARAM['success'] = '';
}
require joinPath($config['iframe_folder'], "includes", "config.php");
if (!isset($system_installed) or !$system_installed) {
    header('Location:' . $rel . 'install/');
    exit;
}
Пример #6
0
<?php

require './src/functions.php';
require './src/menu.php';
require_once './src/workflows.php';
// $begin_time = computeTime();
// Report all PHP errors
//error_reporting(E_ALL);
error_reporting(0);
$w = new Workflows('com.vdesabou.spotify.mini.player');
$query = escapeQuery($argv[1]);
// thanks to http://www.alfredforum.com/topic/1788-prevent-flash-of-no-result
$query = iconv('UTF-8-MAC', 'UTF-8', $query);
//
// check for library update in progress
$update_in_progress = false;
if (file_exists($w->data() . '/update_library_in_progress')) {
    $in_progress_data = $w->read('update_library_in_progress');
    $update_library_in_progress_words = explode('▹', $in_progress_data);
    $elapsed_time = time() - $update_library_in_progress_words[3];
    $update_in_progress = true;
    if (!file_exists($w->data() . '/library_old.db')) {
        if (startsWith($update_library_in_progress_words[0], 'Init')) {
            if ($elapsed_time < 1800) {
                $w->result(null, $w->data() . '/update_library_in_progress', 'Initialization phase since ' . beautifyTime($elapsed_time, true) . ' : ' . floatToSquares(0), 'Waiting for Spotify servers to return required data, it may take time depending on your library', './images/update_in_progress.png', 'no', null, '');
            } else {
                $w->result(null, '', 'There is a problem, the initialization phase took more than 30 minutes', 'Choose kill update library below, and report to the author', './images/warning.png', 'no', null, '');
                $w->result(null, serialize(array('', '', '', '', '', '', '', 'kill_update', $alfred_playlist_uri, '', '', '', '', '', '', '', '', $alfred_playlist_name, $now_playing_notifications, $is_alfred_playlist_active, $country_code, $userid)), 'Kill update library', 'This will stop the library update', './images/kill.png', 'yes', '');
            }
        } else {
            if ($update_library_in_progress_words[0] == 'Refresh Library') {