저자: guiguiboy
예제 #1
0
파일: index.php 프로젝트: vitormattos/a21
<?php

use ProgressBar\Manager;
require 'vendor/autoload.php';
$json = json_decode(file_get_contents('a21.json'), true);
$db = new PDO('sqlite:a21.sqlite3');
$book = $db->query('SELECT * FROM book;');
while ($row = $book->fetch(\PDO::FETCH_ASSOC)) {
    $books[utf8_decode($row['name'])] = $row['id'];
}
$progressBar = new Manager(0, count($json['pages']));
foreach ($json['pages'] as $key => $page) {
    $progressBar->update($key);
    $db->prepare('INSERT INTO verse (book_id,chapter,verse,text) ' . 'VALUES (:book_id, :chapter, :verse, :text);')->execute(array(':book_id' => $page['id'], ':chapter' => $page['cap'], ':verse' => $page['tags'], ':text' => preg_replace('/<b>.*<\\/b>[ ]{0,}/', '', $page['text'])));
}
예제 #2
0
function clearExpiredFiles(ExpiredFileManager $expiredManager)
{
    $expiredFiles = $expiredManager->getExpiredFileList();
    $progressBar = new ProgressBarManager(0, count($expiredFiles));
    $progressBar->setFormat("   - Clearing Expired Files: %current%/%max% [%bar%] %percent%%");
    foreach ($expiredFiles as $file) {
        if (file_exists($file)) {
            unlink($file) and $expiredManager->delete($file);
        } else {
            $expiredManager->delete($file);
        }
        $progressBar->advance();
    }
}
예제 #3
0
 */
if (file_exists(__DIR__ . '/config.php')) {
    $config = (require __DIR__ . '/config.php');
} else {
    $config = (require __DIR__ . '/config.default.php');
}
$cachedir = $config->cachedir;
$packagejson = json_decode(file_get_contents($cachedir . 'packages.json'));
$j = 0;
$errors = array();
$providerCounter = 1;
$numberOfProviders = count((array) $packagejson->{'provider-includes'});
foreach ($packagejson->{'provider-includes'} as $tpl => $provider) {
    $providerjson = str_replace('%hash%', $provider->sha256, $tpl);
    $packages = json_decode(file_get_contents($cachedir . $providerjson));
    $progressBar = new ProgressBarManager(0, count((array) $packages->providers));
    $progressBar->setFormat("      - Package: %current%/%max% [%bar%] %percent%%");
    echo "   - Check Provider {$providerCounter}/{$numberOfProviders}:\n";
    foreach ($packages->providers as $tpl2 => $sha) {
        if (!file_exists($file = $cachedir . "p/{$tpl2}\${$sha->sha256}.json")) {
            $errors[] = "   - {$tpl}\t{$tpl2} file not exists\n";
        } elseif ($sha->sha256 !== hash_file('sha256', $file)) {
            unlink($file);
            $errors[] = "   - {$tpl}\t{$tpl2}\tsha256 not match: {$sha->sha256}\n";
        } else {
            ++$j;
        }
        $progressBar->advance();
    }
    ++$providerCounter;
}
 /**
  * Tests ETA
  */
 public function testEta()
 {
     $manager = new Manager(0, 10, 120);
     $manager->setFormat('%eta%');
     $advancement = array(0 => time() - 2);
     $manager->getRegistry()->setValue('advancement', $advancement);
     $manager->update(1);
     $this->assertRegExp("/00:00:18\\s+\\r/", ob_get_contents());
 }