コード例 #1
0
ファイル: twister.php プロジェクト: alexpagnoni/php-pdb
function StoreAsPRC($title, $rawData)
{
    // echo "<h1>$title</h1>\n<pre>$rawData\n</pre>\n"; return;
    global $SavedPDB, $UncompressedDoc, $TargetType, $CompressWarningDisplayed;
    $fileName = preg_replace('/[^-a-zA-Z_0-9]/', '_', $title);
    if (!isset($SavedPDB) || !is_array($SavedPDB)) {
        $SavedPDB = array();
        session_register('SavedPDB');
    }
    $SavedInfo['Title'] = $title;
    $SavedInfo['Type'] = $TargetType;
    $SavedInfo['Time'] = time();
    if ($TargetType == 'DOC') {
        if (isset($UncompressedDoc) && $UncompressedDoc) {
            $prc = new PalmDoc($title, false);
        } else {
            $prc = new PalmDoc($title);
        }
        $prc->AddDocText($rawData);
        if (!isset($CompressWarningDisplayed)) {
            $WarningTime = '';
            if (count($prc->Records) > 5) {
                $WarningTime = 'a bit';
            }
            if (count($prc->Records) > 10) {
                $WarningTime = 'a while';
            }
            if (count($prc->Records) > 15) {
                $WarningTime = 'a long time';
            }
            if (count($prc->Records) > 25) {
                $WarningTime = 'a very long time';
            }
            if (count($prc->Records) > 40) {
                $WarningTime = 'enough time to write a poem';
            }
            if (count($prc->Records) > 60) {
                $WarningTime = 'enough time for you learn a new hobby';
            }
            if (count($prc->Records) > 100) {
                $WarningTime = 'so long that PHP will likely time out and ' . 'kill this conversion';
            }
            if ($WarningTime != '') {
                ShowStatus("Compressing the DOC.\nThis could take " . $WarningTime . '.');
            }
            $CompressWarningDisplayed = true;
        }
    } elseif ($TargetType == 'SmallBASIC') {
        $prc = new PalmSmallBASIC($title);
        $result = $prc->ConvertFromText($rawData);
        if (is_array($result)) {
            ShowError('Error converting the file.  The section "' . $result[1] . '" is too big.  It must be broken into ' . 'multiple sections for the conversion to work.');
            return;
        }
    }
    ob_start();
    $prc->WriteToStdout();
    $prc = ob_get_contents();
    ob_end_clean();
    $SavedInfo['Data'] = $prc;
    $key = $fileName;
    $num = 1;
    while (isset($SavedPDB[$key])) {
        $num++;
        $key = $fileName . '-' . $num;
    }
    $SavedPDB[$key] = $SavedInfo;
}
コード例 #2
0
ファイル: pdb-test.php プロジェクト: hxpro/php-pdb
function SmallBASICTest()
{
    $d = new PalmSmallBASIC('pen.bas');
    $text = "! pen                     \n" . "\n" . "print \"Use /B (Graffiti) to exit\"\n" . "\n" . "pen on\n" . "while 1\n" . " if pen(0)\n" . "  line pen(4),pen(5)\n" . " fi\n" . "wend\n" . "pen off\n";
    $text = str_replace('!', '\'', $text);
    $text = str_replace("\r\n", "\n", $text);
    $text = str_replace("\r", "\n", $text);
    $d->ConvertFromText($text);
    return GenerateMd5($d);
}
コード例 #3
0
ファイル: pdb-test.php プロジェクト: alexpagnoni/php-pdb
function SmallBASICTest()
{
    $d = new PalmSmallBASIC("pen.bas");
    $text = <<<EOS
' pen

print "Use /B (Graffiti) to exit"

pen on
while 1
 if pen(0)
  line pen(4),pen(5)
 fi
wend
pen off
EOS;
    $text = str_replace("\r\n", "\n", $text);
    $text = str_replace("\r", "\n", $text);
    $d->ConvertFromText($text);
    return GenerateMd5($d);
}