Esempio n. 1
0
            if ($outputUnit == '\'' && $resultNumber > 50) {
                $outputUnit = 'yards';
                $resultNumber /= 3;
                $spaceFlag = 1;
            } else {
                if ($outputUnit == '°C') {
                    $resultNumber = ($resultNumber - 32) * 5 / 9;
                } else {
                    if ($outputUnit == '°F') {
                        $resultNumber = $resultNumber * 9 / 5 + 32;
                    }
                }
            }
            // the whitespace to output between number an unit. mirror input unless 'space' flag is set
            if ($spaceFlag === 0) {
                $space = '';
            } else {
                if ($spaceFlag === 1) {
                    $space = ' ';
                } else {
                    $space = $matches[3];
                }
            }
            return str_replace($whole, number_format($resultNumber, places($numberPart), DECIMAL_SEPARATOR, '') . $space . $outputUnit, $text);
        }
    }
    return NULL;
}
if ($input = getenv('POPCLIP_TEXT')) {
    echo doConvert($input);
}
Esempio n. 2
0
	<li><a href="?mode=import">匯入目前中介檔案到 Another-PIO (請修改此頁 PHP 設定)</a></li>
	<li><a href="?mode=convert">將目前 PIO 資料轉換到 Another-PIO</a></li>
</ul>
<hr />
<div id="result">
<?php 
$mode = isset($_GET['mode']) ? $_GET['mode'] : '';
switch ($mode) {
    case 'export':
        doExport();
        break;
    case 'import':
        doImport();
        break;
    case 'convert':
        doConvert();
        break;
}
function doExport()
{
    global $PIOEnv;
    if (preg_match('/^(.*):\\/\\//i', CONNECTION_STRING, $backend)) {
        define('PIO_FROM', $backend[1]);
    }
    include './lib/pio/pio.' . PIO_FROM . '.php';
    $pio1 = 'PIO' . PIO_FROM;
    $PIO = new $pio1(CONNECTION_STRING, $PIOEnv);
    $gp = gzopen('piodata.log.gz', 'w9');
    gzwrite($gp, $PIO->dbExport());
    gzclose($gp);
    echo '<a href="piodata.log.gz">下載 piodata.log.gz 中介檔案</a>';
Esempio n. 3
0
<?php

include 'unixtime.php';
$testData = array('1366890005', 'Thu, 25 Apr 2013 11:40:05 +0000');
$fail = FALSE;
for ($i = 0; $i < count($testData); $i += 2) {
    $testValue = $testData[$i];
    $expect = $testData[$i + 1];
    $result = doConvert($testValue);
    $pass = $result === $expect;
    if (!$pass) {
        $fail = TRUE;
    }
    echo $testValue . ' -> ' . $result . ' ' . ($pass ? 'OK' : 'FAIL') . "\n";
}
echo ($fail ? "FAILED" : "PASSED") . "\n";