Exemplo n.º 1
0
function load($dir)
{
    $wf = new Workflows();
    $enable_cache = $GLOBALS["enable_cache"];
    $cache_file = $wf->cache() . "/cache-" . preg_replace('/[^a-z0-9_-]/i', '', $GLOBALS["url"]);
    $GLOBALS["cache_file"] = $cache_file;
    if ($enable_cache) {
        // echo "cache file is $cache_file\n";
        $cache_time = 5 * 60;
        // 5min
        if (file_exists($cache_file)) {
            $entry = getCachedItem($dir);
            if ($entry) {
                return $entry;
            }
        } else {
            file_put_contents($cache_file, serialize(array()));
        }
    }
    $options = array(CURLOPT_CONNECTTIMEOUT => 10, CURLOPT_USERPWD => $GLOBALS["username"] . ':' . $GLOBALS["password"], CURLOPT_FAILONERROR => true, CURLOPT_CUSTOMREQUEST => "LIST {$dir}");
    $lines = explode("\n", $wf->request($GLOBALS["url"], $options));
    // print_r($lines);
    $list = array();
    foreach ($lines as $line) {
        if (empty($line)) {
            continue;
        }
        preg_match_all('/(?P<flag>[dl-])[rwx-]+\\s+(?P<contents>\\d+).+?(?P<size>\\d+)\\s+(?P<month>\\w+)\\s+(?P<date>\\d+)\\s+(?P<time_or_year>[\\d:]+)\\s+(?P<name>\\S+)/', $line, $out, PREG_SET_ORDER);
        // ignore invalid line
        if (!count($out)) {
            continue;
        }
        $match = $out[0];
        $pattern = strpos($match["time_or_year"], ':') === false ? "Y" : "H:i";
        $timezone = new DatetimeZone($GLOBALS["server_timezone"]);
        $date = DateTime::createFromFormat("M d {$pattern}", $match["month"] . " " . $match["date"] . " " . $match["time_or_year"], $timezone);
        if ($date > date_create("now", $timezone)) {
            $date->sub(new DateInterval("P1Y"));
        }
        $timestamp = $date->getTimestamp();
        $keys = array('name', 'size', 'flag');
        $match = array_intersect_key($match, array_flip($keys));
        $match["timestamp"] = $timestamp;
        $match["lastmodifieddate"] = $date->format($GLOBALS["date_format"]);
        $list["{$timestamp}-" . $match['name']] = $match;
    }
    krsort($list);
    if ($enable_cache) {
        $data = unserialize(file_get_contents($cache_file));
        $data[$dir] = array('ts' => time(), 'list' => $list);
        file_put_contents($cache_file, serialize($data));
    }
    return $list;
}
Exemplo n.º 2
0
 function __construct($a = "database.db")
 {
     require_once 'workflows.php';
     $w = new Workflows();
     $this->cache = $w->cache();
     $this->data = $w->data();
     $this->bundle = $w->bundle();
     $this->path = $w->path();
     $this->home = $w->home();
     if (file_exists($this->data . '/' . $a)) {
         $a = $this->data . '/' . $a;
     } elseif (file_exists($this->cache . '/' . $a)) {
         $a = $this->cache . '/' . $a;
     } elseif (file_exists($this->path . '/' . $a)) {
         $a = $this->path . '/' . $a;
     } elseif (file_exists($a)) {
         // do nothing.
     } else {
         $a = $this->data . '/' . $a;
     }
     $this->open($a);
 }
Exemplo n.º 3
0
            $color = format($reveal[1], jsonrgba($color));
            var_dump($color);
            if ($color) {
                search($color);
            }
            return;
        }
        $color = colorpicker(jsonrgba($reveal[1]));
        $color = jsonrgba($color);
        if ($color) {
            search(format($reveal[0], jsonrgba($color)));
        }
        return;
        break;
    case 'clear':
        $files = glob($w->cache() . '/*');
        // get all file names
        foreach ($files as $file) {
            // iterate files
            if (is_file($file)) {
                unlink($file);
            }
            // delete file
        }
        return;
        break;
}
if ($rgba == false) {
    noresult($mode, 'No Color Matches');
    echo $w->toxml();
    return;
Exemplo n.º 4
0
    }
}
exec("mkdir -p ~/Downloads/spot_mini_debug");
$output = "DEBUG: ";
//
// check for library update in progress
if (file_exists($w->data() . "/update_library_in_progress")) {
    $w->result('', '', "Library update in progress", "", 'fileicon:' . $w->data() . '/update_library_in_progress', 'no', null, '');
    $output = $output . "Library update in progress: " . "the file" . $w->data() . "/update_library_in_progress is present\n";
}
if (!file_exists($w->data() . "/settings.json")) {
    $output = $output . "The file " . $w->data() . "/settings.json is not present\n";
} else {
    copy($w->data() . "/settings.json", $w->home() . "/Downloads/spot_mini_debug/settings.json");
}
copyDirectory($w->cache(), $w->home() . "/Downloads/spot_mini_debug/cache");
if (!file_exists($w->data() . "/fetch_artworks.db")) {
    $output = $output . "The file " . $w->data() . "/fetch_artworks.db is not present\n";
} else {
    copy($w->data() . "/fetch_artworks.db", $w->home() . "/Downloads/spot_mini_debug/fetch_artworks.db");
}
if (!file_exists($w->data() . "/library.db")) {
    $output = $output . "The file " . $w->data() . "/library.db is not present\n";
} else {
    copy($w->data() . "/library.db", $w->home() . "/Downloads/spot_mini_debug/library.db");
}
if (!file_exists($w->data() . "/library_new.db")) {
    $output = $output . "The file " . $w->data() . "/library_new.db is not present\n";
} else {
    copy($w->data() . "/library_new.db", $w->home() . "/Downloads/spot_mini_debug/library_new.db");
}
Exemplo n.º 5
0
            echo $q;
        }
        return;
        break;
}
if ($rgba == false) {
    $w->result('tylereich.colors-noresults', '', 'No matching colors were found', 'Make sure you spelled your query correctly.', 'icon.png', 'no');
    echo $w->toxml();
    return;
}
$r = $rgba[0];
$g = $rgba[1];
$b = $rgba[2];
$a = $rgba[3];
$hexraw = tohexraw($r, $g, $b, $a);
if (!$w->read($w->cache() . "/{$hexraw}.png")) {
    $img_rgba = array(round($r * 255), round($g * 255), round($b * 255), round(abs($a - 1) * 127));
    $img = imagecreatefrompng('checker.png');
    $color = imagecolorallocatealpha($img, $img_rgba[0], $img_rgba[1], $img_rgba[2], $img_rgba[3]);
    imagefilledrectangle($img, 8, 8, 120, 120, $color);
    imagepng($img, $w->cache() . "/{$hexraw}.png");
    imagedestroy($img);
}
if ($a == 1) {
    $a = false;
}
$hex = tohex($r, $g, $b, $a);
//$hexraw = tohexraw($r,$g,$b,$a);
$hsl = tohsl($r, $g, $b, $a);
$name = toname(tohexraw($r, $g, $b));
$rgb = torgb($r, $g, $b, $a);
<?php

require './src/functions.php';
require_once './src/workflows.php';
$w = new Workflows('com.vdesabou.spotify.mini.player');
$query = $argv[1];
if (mb_strlen($query) > 1) {
    if (startsWith($query, 'DB Exception')) {
        $w->result(null, '', 'DB Exception occurred: ' . $query, 'Try to re-create library as explained below.', './images/warning.png', 'no', null, '');
        $w->result(uniqid(), '', 'There is a problem with the library, try to re-create it.', 'Select Re-Create Library library below', './images/warning.png', 'no', null, '');
        $w->result(uniqid(), serialize(array('', '', '', '', '', '', '', 'update_library', '', '', '', '', '', '', '', '', '', '')), "Re-Create Library", "when done you'll receive a notification. you can check progress by invoking the workflow again", './images/update.png', 'yes', null, '');
    } elseif (startsWith($query, 'AppleScript Exception')) {
        $w->result(null, 'help', "AppleScript execution failed!", "Message: " . $query, './images/warning.png', 'no', null, '');
        $w->result(null, serialize(array('', '', '', '', '', '', 'Open▹' . 'http://alfred-spotify-mini-player.com/blog/issue-with-latest-spotify-update/', '', '', '', '', '', '', '', '', '')), 'Maybe you have an issue with a Broken Spotify version?', "Go to the article to get more information", './images/website.png', 'yes', null, '');
    } elseif (startsWith($query, 'Mopidy Exception')) {
        $w->result(null, 'help', "Mopidy execution failed!", "Message: " . $query, './images/warning.png', 'no', null, '');
        $w->result(null, serialize(array('', '', '', '', '', '', 'Open▹' . 'http://alfred-spotify-mini-player.com/articles/mopidy/', '', '', '', '', '', '', '', '', '')), 'Is Mopidy correctly installed and running?', "Go to the article to get more information", './images/website.png', 'yes', null, '');
    } else {
        $w->result(null, '', 'Exception occurred: ' . $query, 'Use the Send an email to the author option below to send generated spot_mini_debug.tgz', './images/warning.png', 'no', null, '');
    }
}
$w->result(null, serialize(array('', '', '', '', '', '', '', 'spot_mini_debug', '', '', '', '', '', '', '', '')), 'Send an email to the author with a link to generated spot_mini_debug.tgz file', "This will open your default mail application, with all needed information for troubleshooting.", './images/mail.png', 'yes', null, '');
$w->result(null, '', 'Quick access to workflow folders:', '', './images/info.png', 'no', null, '');
$w->result(null, serialize(array('', '', '', '', '', '', 'Open▹' . $w->data(), '', '', '', '', '', '', '', '', '', '', '', '', '', '', '')), 'Browse to App Support Folder', "This will open the folder in Finder", 'fileicon:' . $w->data(), 'yes', null, '');
$w->result(null, serialize(array('', '', '', '', '', '', 'Open▹' . $w->cache(), '', '', '', '', '', '', '', '', '', '', '', '', '', '', '')), 'Browse to Workflow Cache Folder', "This will open the folder in Finder", 'fileicon:' . $w->cache(), 'yes', null, '');
$w->result(null, serialize(array('', '', '', '', '', '', 'Open▹' . exec('pwd'), '', '', '', '', '', '', '', '', '', '', '', '', '', '', '')), 'Browse to Alfred workflow folder', "This will open the folder in Finder", 'fileicon:' . exec('pwd'), 'yes', null, '');
echo $w->toxml();
Exemplo n.º 7
0
<?php

//include('simple_html_dom.php');
$split_symbol = " : ";
$route = 0;
require_once 'workflows.php';
include 'simple_html_dom.php';
$query = $argv[1];
$w = new Workflows();
$cache = $w->cache();
$routes = array(100 => "Division", 101 => "Northbound", 102 => "Southbound", 200 => "Kalamazoo", 201 => "Northbound", 202 => "Southbound", 300 => "Madison", 301 => "Northbound", 302 => "Southbound", 400 => "Eastern", 401 => "Northbound", 402 => "Southbound", 500 => "Wealthy/Woodland", 501 => "Northbound", 502 => "Southbound", 600 => "Eastown/Woodland", 601 => "Northbound", 602 => "Southbound", 700 => "West Leonard", 701 => "Eastbound", 702 => "Westbound", 800 => "Grandville/Rivertown", 801 => "Northbound", 802 => "Southbound", 900 => "Alpine", 901 => "Northbound", 902 => "Southbound", 1000 => "Clyde Park", 1001 => "Northbound", 1002 => "Southbound", 1100 => "Plainfield", 1101 => "Northbound", 1102 => "Southbound", 1200 => "West Fulton", 1201 => "Westbound", 1202 => "Eastbound", 1300 => "Michigan/Fuller North", 1301 => "Northbound", 1302 => "Southbound", 1400 => "East Fulton", 1401 => "Westbound", 1402 => "Eastbound", 1500 => "East Leonard", 1501 => "Eastbound", 1502 => "Westbound", 1600 => "Wyoming/Metro Health", 1601 => "Northbound", 1602 => "Southbound", 1700 => "Woodland Mall/Airport", 1701 => "Northbound", 1702 => "Southbound", 1800 => "Westside", 1801 => "Westbound", 1802 => "Eastbound", 1900 => "Michigan/Fuller South", 1901 => "Northbound", 1902 => "Southbound", 2400 => "Burton Crosstown", 2401 => "Westbound", 2402 => "Eastbound", 2800 => "28th St. Crosstown", 2801 => "Westbound", 2802 => "Eastbound", 3700 => "North Campus (GVSU)", 3701 => "Loop", 4400 => "44th St. Crosstown", 4401 => "Westbound", 4402 => "Eastbound", 4800 => "South Campus (GVSU)", 4801 => "Loop", 5000 => "GVSU Connector", 5001 => "Westbound", 5002 => "Eastbound", 6000 => "GRCCC", 6001 => "Westbound", 6002 => "Eastbound", 8500 => "Combined 37/48 (GVSU)", 8501 => "Loop", 9000 => "Silver Line", 9001 => "Northbound", 9002 => "Southbound");
//parse query
$parts = explode($split_symbol, $query);
if (count($parts) > 1) {
    //match route
    $matched_route = false;
    $main_route = 0;
    reset($parts);
    foreach ($routes as $key => $name) {
        if ($key % 100 == 0 && strcmp(strtolower(preg_replace("/[^a-zA-Z0-9]+/", "", $name)), strtolower(preg_replace("/[^a-zA-Z0-9]+/", "", current($parts)))) === 0) {
            $matched_route = true;
            $main_route = $key;
            break;
        }
    }
    $route = $main_route;
}
if (count($parts) > 2) {
    //match direction
    $matched_route = false;
    $direction = 0;
Exemplo n.º 8
0
Arquivo: debug.php Projeto: bycEEE/env
    }
}
exec("mkdir -p ~/Downloads/spot_mini_debug");
$output = "DEBUG: ";
//
// check for library update in progress
if (file_exists($w->data() . "/update_library_in_progress")) {
    $w->result('', '', "Library update in progress", "", 'fileicon:' . $w->data() . '/update_library_in_progress', 'no', null, '');
    $output = $output . "Library update in progress: " . "the file" . $w->data() . "/update_library_in_progress is present\n";
}
if (!file_exists($w->data() . "/settings.json")) {
    $output = $output . "The file " . $w->data() . "/settings.json is not present\n";
} else {
    copy($w->data() . "/settings.json", $w->home() . "/Downloads/spot_mini_debug/settings.json");
}
copy_directory($w->cache(), $w->home() . "/Downloads/spot_mini_debug/cache");
if (!file_exists($w->data() . "/fetch_artworks.db")) {
    $output = $output . "The file " . $w->data() . "/fetch_artworks.db is not present\n";
} else {
    copy($w->data() . "/fetch_artworks.db", $w->home() . "/Downloads/spot_mini_debug/fetch_artworks.db");
}
if (!file_exists($w->data() . "/library.db")) {
    $output = $output . "The file " . $w->data() . "/library.db is not present\n";
} else {
    copy($w->data() . "/library.db", $w->home() . "/Downloads/spot_mini_debug/library.db");
}
if (!file_exists($w->data() . "/library_new.db")) {
    $output = $output . "The file " . $w->data() . "/library_new.db is not present\n";
} else {
    copy($w->data() . "/library_new.db", $w->home() . "/Downloads/spot_mini_debug/library_new.db");
}