コード例 #1
0
ファイル: index.php プロジェクト: Timothee/Notwilfications
function ping()
{
    if (verifySignature()) {
        echo "{success: 1, message: 'Success: your settings are correct.'}";
    } else {
        echo "{success: 0, message: 'Error: we could not verify the signature. Check your settings.'}";
    }
}
コード例 #2
0
ファイル: packal.php プロジェクト: jesseflorig/config
/**
 * [doUpdate description]
 * @param {[type]} $bundle [description]
 * @param {[type]} $force  =             FALSE [description]
 */
function doUpdate($bundle, $force = FALSE)
{
    global $data, $cache, $manifest, $repo, $cliDir;
    if (is_array($bundle)) {
        $bundle = $bundle[0];
    }
    $dir = trim(`"{$cliDir}/packal.sh" getDir "{$bundle}"`);
    // echo $dir;
    // The force variable means to download even if the original
    // is not from Packal. Obviously, since we don't have the
    // update data, this just means to download the update no
    // matter what and to get everything.
    if (!$force) {
        if (!file_exists("{$dir}/packal/package.xml")) {
            echo "Error: No package information exists.";
            return FALSE;
        }
    }
    $xml = simplexml_load_file("{$manifest}");
    foreach ($xml as $x) {
        if ("{$x->bundle}" != "{$bundle}") {
            continue;
        }
        $xml = $x;
        break;
    }
    // Make the temporary directories.
    if (!file_exists("{$cache}/update")) {
        mkdir("{$cache}/update");
    }
    if (!file_exists("{$cache}/update/{$bundle}")) {
        mkdir("{$cache}/update/{$bundle}");
    }
    if (!file_exists("{$cache}/update/{$bundle}/tmp")) {
        mkdir("{$cache}/update/{$bundle}/tmp");
    }
    `curl -sL "{$repo}/{$bundle}/{$xml->file}" > "{$cache}/update/{$bundle}/{$xml->file}"`;
    `curl -sL "{$repo}/{$bundle}/appcast.xml" > "{$cache}/update/{$bundle}/appcast.xml"`;
    `unzip -qo "{$cache}/update/{$bundle}/{$xml->file}" -d "{$cache}/update/{$bundle}/tmp"`;
    $valid = verifySignature("{$cache}/update/{$bundle}/appcast.xml", "{$cache}/update/{$bundle}/{$xml->file}", "{$dir}/packal/{$bundle}.pub");
    if (!$valid) {
        echo "Error: Cannot verify signature for {$xml->file} from {$bundle}.";
        return FALSE;
    }
    // Why can't I just include the function, call it, and be done with it?
    // I think it might be a namespacing issue or something.
    // migratePlist( "$dir/info.plist", "$cache/update/$bundle/tmp/info.plist" );
    // It's too late to figure that out. Maybe tomorrow.
    $cmd = "php " . __DIR__ . "/includes/plist-migration.php \"{$dir}/info.plist\" \"{$cache}/update/{$bundle}/tmp/info.plist\"";
    exec("{$cmd}");
    // Backup the bundle.
    echo `"{$cliDir}/packal.sh" backup "{$bundle}"`;
    $cmd = "'" . __DIR__ . "/packal.sh' replaceFiles " . escapeshellarg($dir) . ' ' . escapeshellarg($cache . '/update/' . "{$bundle}/tmp/");
    exec("{$cmd}");
    `rm -fR "{$cache}/update/{$bundle}"`;
    $tn = __load('terminal-notifier', 'default', 'utility');
    exec("{$tn} -title 'Packal Updater' -message '{$xml->name} has been updated to version {$xml->version}'");
    echo "TRUE";
    return TRUE;
}